I am not able to figure out how to order the records that fill the
drop down list in a model form. On line 112 below, I have attempted
to order the Rotation model by player. But, the drop down list that
is created for me is not ordered that way. I also tried relocating
line 112 to within the Meta class definition. But, that didn't work
either. I see field ordering in the docs. But, I don't see this
mentioned.
Any suggestions would be more than appreciated.
101 class Rotation(models.Model):
102 player = models.ForeignKey(Person, to_field='f_name',
verbose_name='Player', limit_choices_to={'relationship' : 'Player'})
103 date = models.DateField('Date', default=datetime.date.today)
104 game_type = models.CharField("Game Type",
choices=(('Scrimmage', 'Scrimmage'), ('Tournament', 'Tournament')),
max_length=10)
105 inning_count = models.IntegerField("Innings Out", default=1)
106 def __unicode__(self):
107 return '%s || %s %s || %s || %s' % (self.date,
self.player.f_name, self.player.l_name, self.game_type,
str(self.inning_count))
108 class Meta:
109 ordering = ['date']
110
111 class RotationForm(forms.ModelForm):
112 Rotation.objects.order_by('player')
113 class Meta:
114 model = Rotation
115 exclude = ['date', 'inning_count']
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.