How do I fix Django returning 'self' not defined NameError on queryset filtering of ModelChoiceField?

I have 2 models, Type and Measure. Each Measure object has a typeid ForeignKey field that refers to the id field of a Type object. Each Type is viewed on it’s own page where the id is passed through URL. urls.py urlpatterns = [ path(‘type/<int:id>’, views.type, name=’type’), ] The view had been working with this… Read More How do I fix Django returning 'self' not defined NameError on queryset filtering of ModelChoiceField?

How do I fix Django returning 'self' not defined NameError on queryset filtering of ModelChoiceField?

I have 2 models, Type and Measure. Each Measure object has a typeid ForeignKey field that refers to the id field of a Type object. Each Type is viewed on it’s own page where the id is passed through URL. urls.py urlpatterns = [ path(‘type/<int:id>’, views.type, name=’type’), ] The view had been working with this… Read More How do I fix Django returning 'self' not defined NameError on queryset filtering of ModelChoiceField?

How to create combobox with django model?

i want to create something like a combo box with django model, but i don’t find any field type to do that. something like this: enter image description here >Solution : Simply you can do this in models.py: class Student(models.Model): select_gender = ( (‘Male’, ‘Male’), (‘Female’, ‘Female’), (‘Other’, ‘Other’), ) student_name = models.CharField(max_length=100) student_gender =… Read More How to create combobox with django model?