Hey RJ,

I'm not seeing the problem you're having. If i have a model like this:

class MyModel(models.Model):
   field = models.CharField(max_length=100)

   class Meta:
      ordering = ['id']   # Ascending by id
      #ordering = ['-id'] # Descending by id

This works just fine for me. Flipflop the comments to toggle ascending
vs descending.

Hope this helps,

Dan Harris
[email protected]

On Jun 5, 9:16 pm, rahul jain <[email protected]> wrote:
> Hi Django,
>
> I tried lots of different ways to get my ids listed in ascending order
> (1 - x). But it always displays id's (x -1).
>
> This is what I tried
>
> So, I am talking about auto increment id which is generated by default
> by Django.
>
> on models admin
> ordering = ('-id',)
>
> also i tried
>
> on class meta
>
> order_by = ('-id',)
>
> This is only happening with auto-increment primary key i.e id. Not
> with others. Manually I can set it by going to admin
> and then sorting. But I need to set the default ascending order
> sorting for id's.
>
> Is it a bug or something I am missing.
>
> --RJ

-- 
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