49๐
โ
It should be:
foundContacts.order_by("classification__kam")
Here is a link for the Django docs on making queries that span relationships: https://docs.djangoproject.com/en/dev/topics/db/queries/#lookups-that-span-relationships
You can also see some examples in the order_by
reference:
https://docs.djangoproject.com/en/dev/ref/models/querysets/#django.db.models.query.QuerySet.order_by
๐คMark Lavin
0๐
as the documentation indicates, it should be used as in queries about related models
https://docs.djangoproject.com/en/3.0/ref/models/querysets/#order-by
foundContacts.order_by("classification__kam")
- [Django]-Where can I find the error logs of nginx, using FastCGI and Django?
- [Django]-Is it secure to store passwords as environment variables (rather than as plain text) in config files?
- [Django]-Writing unit tests in Django / Python
0๐
Iโve struggled a lot with this problem, this is how I solved it:
- contact ordered by "kam" (Classification) field:
show_all_contact = Contact.objects.all().order_by(title__kam)
- classification ordered by Users email (no sense in it, but only show how it works):
show_all_clasification = Classification.objects.all().order_by(kam__email)
๐คoruchkin
- [Django]-Filtering only on Annotations in Django
- [Django]-Customizing JWT response from django-rest-framework-simplejwt
- [Django]-Use "contains" and "iexact" at the same query in DJANGO
Source:stackexchange.com