4👍
✅
You should be able to use:
App.objects.annotate(release_count=Count('release')).filter(release_count__gt=0)\
.order_by('-release__date')
2👍
App.objects \
.annotate(release_count=Count('release')) \
.(release_count__gt=0) \
.order_by('-release_count')
For the bonus part, denormalizing date field looks like the only solution at the moment. And it’s pretty fast too.
- [Django]-How to filter model with a list containing the field and the value?
- [Django]-Why do I get a base_name attribute error when I include my view in a django Mongoengine web service url.py file?
- [Django]-Django messages framework with built-in Jinja2 backend
- [Django]-CMS or web framework a simple project
- [Django]-Ignore_user_abort php simil in Django/python?
Source:stackexchange.com