# later in forms.py
category = forms.TypedChoiceField(required=False, choices=get_categories)

This has a similar effect to the ModelChoiceField, with the query only
running when the form is instantiated, but gives you the flexibility to use
whatever logic you'd like to come up with the choices for the field.


Forgot the doc link:


https://docs.djangoproject.com/en/1.11/ref/forms/fields/#django.forms.ChoiceField.choices

-James

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2Be%2BciVq8Dsxz2uw6NOJJcnAniDuiEY5qU6NKKDAYmOhWk%3DMVw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to