default ordering django

Add a Meta class inside the model class:

class YourModel(models.Model):
    # model fields

    class Meta:
        ordering = ['field1', '-field2']

Explanations for each step: 1. The Meta class is used to define metadata for the model. 2. The 'ordering' attribute inside the Meta class specifies the default ordering of the model's records. 3. You can use the prefix '-' to indicate descending order for a specific field.