Timtables should also be Timetables On Tue, Sep 11, 2012 at 9:30 PM, m1chael <myk...@gmail.com> wrote:
> it looks like you have a syntax error here: > > timetable = > forms.ModelChoiceField(queryset=Timtables.objects.all.ordered_by('-date') > > should be: > > timetable > = forms.ModelChoiceField(queryset=Timtables.objects.all.ordered_by('-date')) > # added a ) > > > > > On Tue, Sep 11, 2012 at 9:26 PM, Lachlan Musicman <data...@gmail.com>wrote: > >> Hi >> >> Is there anyway to import the choices from my models.py into my >> forms.py to prevent code duplication? >> >> At the moment I've got the following, but I'm getting invalid sytax >> errors in my forms.py: >> -------------------- >> models.py : >> SESSION_CHOICES = ( >> (u'0',u'Morning 1'), >> (u'1',u'Morning 2'), >> (u'2',u'Afternoon 1'), >> (u'3',u'Afternoon 2'), >> (u'4',u'Evening'), >> (u'5',u'Weekend'), >> ) >> -------------------- >> >> forms.py: >> >> from django import forms >> from tafe.models import Session, Timetable, Subject >> from tafe.models import SESSION_CHOICES >> >> class SessionRecurringForm(forms.Form): >> subject = forms.ModelChoiceField(queryset=Subject.objects.all) >> timetable = >> forms.ModelChoiceField(queryset=Timtables.objects.all.ordered_by('-date') >> session_number = forms.ChoiceField(choice=SESSION_CHOICES) >> >> >> Is what I'm trying to do possible? I feel like I've seen someone do it >> before, but it was in an unrelated code snippet, and I've no idea >> where I found it... >> >> cheers >> L. >> >> -- >> ...we look at the present day through a rear-view mirror. This is >> something Marshall McLuhan said back in the Sixties, when the world >> was in the grip of authentic-seeming future narratives. He said, “We >> look at the present through a rear-view mirror. We march backwards >> into the future.” >> >> http://www.warrenellis.com/?p=14314 >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To post to this group, send email to django-users@googlegroups.com. >> To unsubscribe from this group, send email to >> django-users+unsubscr...@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/django-users?hl=en. >> >> > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.