Hi All
Ive overcome it by adding doing this:
This makes sense. Don't reference objects that will be parsed before they exist
On Thursday, 19 October 2017 10:23:36 UTC+1, Chris Wedgwood wrote:
-- Ive overcome it by adding doing this:
def __init__(self, *args, **kwargs):
super(UniversityForm, self).__init__(*args, **kwargs)
self.fields['name'].choices = University.objects.values_list('id', 'name')
This makes sense. Don't reference objects that will be parsed before they exist
On Thursday, 19 October 2017 10:23:36 UTC+1, Chris Wedgwood wrote:
Hi
I have the following scenario in my forms.py:
UNIVERSITY_CHOICES = University.objects.values_list('id', 'name')
class UniversityForm(forms.Form):
name = forms.CharField(widget=forms.Select(attrs={"class":
"selectpicker", "data-live-search": "true","title": "find
university..."},choices=UNIVERSITY_CHOICES), required=False)
The migration fails as it is expecting the university table to exist
but does not yet.
This is clearly an anti-pattern on my part. What is the correct way to
approach this?
thanks
Chris
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+unsubscribe@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/d5f6e5d8-d03c-4c80-8fcb-fdc061cfc2e3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment