Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django: How to disable ordering in model

Tags:

python

django

Let's say there is a model with default ordering described in Meta class

class People(models.Model):
    first_name  = models.CharField(max_length=100)
    last_name   = models.CharField(max_length=100)
    middle_name = models.CharField(max_length=100)

    class Meta:
        ordering = (last_name, first_name)

Is there are a way to get unordered queryset

like image 903
user1454592 Avatar asked Mar 07 '13 16:03

user1454592


1 Answers

You can just override by simply adding .order_by()

for example:

People.objects.all().order_by()

This will make sure that Meta ordering is overridden.

like image 155
vikalp.sahni Avatar answered Nov 11 '22 02:11

vikalp.sahni