django-autocomplete-light
django-autocomplete-light copied to clipboard
UnorderedObjectListWarning
When using under Python 3.6.1 + Django 1.11.1, there's an warning when hitting the xxxx-autocomplete view:
lib/python3.6/site-packages/django/core/paginator.py:112: UnorderedObjectListWarning: Pagination may yield inconsistent results with an unordered object_list: <QuerySet []> UnorderedObjectListWarning
Can you paste the whole traceback please ?
Or better, propose a patch <3
I'm having the same issue here.
After of bit of searching it turns out it comes from Paginator
which complains because of this remark in Django's documentation.
The fix would be to set the ordering
attribute in the autocomplete view. So the question is :
- should dal's clients systematically set an ordering of their choice? In this case, maybe it would be worth mentioning it the docs, in particular in the tutorial.
- should dal choose a default ordering to prevent the issue? For instance
ordering = ("id", )
Hope I didn't misunderstand the problem.
I'd be happy to propose a patch if you opt for the second option :)
Well, in general you should have a default ordering in YourModel.meta.ordering, not sure if that will fix the issue, but in this case dal should not override the ordering with its own default.
Then, I suppose the ordering that would make sense would be based on the field that the user is searching into.
Feel free to open a PR if you feel strongly about it.
Best