3👍
You are right, Meta Ordering does result in additional time if it is not required. The amount of extra overhead can vary depending on the ordering specified.
This is described in the docs here:
https://docs.djangoproject.com/en/1.11/ref/models/options/#ordering
In light of that, it becomes a design choice. If you always need the Model instances to be in the same order, such as an alphabetical list of product names for sale, then you may want Meta Ordering. If you are processing the Model instances in all kinds of different ways which require different ordering/filtering, then you probably wouldn’t want to incur the overhead of Meta Ordering.
3👍
When you are using the model in a class-based view it is sometimes important to use the first option because it might be a model passed as a ForeignKey
. In this case when referencing it within your template you cannot set the order if you have not added the ordering
in Meta
.
- [Django]-Using Requests python library to connect Django app failed on authentication
- [Django]-Error when creating admin in django tutorial
- [Django]-Django calling no request view function in template
- [Django]-Django StreamingHttpResponse into a Template
- [Django]-Unhandled exception when validating models in Django