You should do it in admin.py

class MyClassAdmin(admin.ModelAdmin):
    ordering = ['-myfield']

On Sun, Jun 13, 2010 at 6:18 AM, darren <[email protected]> wrote:

> I'm sure the answer is probably documented clearly somewhere.  But, I
> can't find it.
>
> I would like to change the ordering of a field in a form on the admin
> site based on the model below.  The "game" column is several records
> long.  I would like to order desc.  I've tried adding a META class to
> my model and tinkering with the admin.py.  But, I haven't been able to
> figure this out.
>
> Could someone point me to the documentation?  I've been reading this:
> http://docs.djangoproject.com/en/1.2/ref/contrib/admin/#ref-contrib-admin,
> but I don't see what I'm looking for there.
>
> Thanks
>
> 104 class AtBat(models.Model):
> 105     atbat_id = models.AutoField(primary_key=True)
> 106     player = models.ForeignKey(Person, to_field='f_name',
> verbose_name='Player', limit_choices_to={'relationship' : 'Player'})
> 107     game = models.ForeignKey(Score, to_field='scores_id',
> verbose_name='Game')
> 108     result = models.CharField('Result', choices=(('H', 'Hit'),
> ('BB', 'Walk'), ('K', 'Strike Out'), ('ROE', 'Reached On Error'),
> ('HBP', 'Hit By Pitch'), ('FO', 'Ground or Fly Out'), ('FC', 'Fielders
> Choice'), ('Sacrifice', 'Sac    rafice')), max_length=10)
> 109     rbi = models.PositiveSmallIntegerField("RBI", default=0)
> 110
> 111     def __unicode__(self):
> 112         return unicode('%s %s %s %s' % (self.atbat_id,
> self.player, self.game, self.result))
>
> --
> 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]<django-users%[email protected]>
> .
> 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 [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.

Reply via email to