0👍
There is a generic way to find the list of all reverse relations of a model.
reverse_model_array = [f.related_model for f in model._meta.get_fields()
if f.auto_created and not f.concrete]
This will list all the models that have reference to this model(foreign key, many to many key, etc)
- How to sort a list of objects in a template in alphabetic order?
- Buildout vs virtualenv + pip for django?
-4👍
I think this will working, but not so efficient:
with_no_site_info = [site for site in Site.objects.all() if site.site_infos_set.all().count() == 0]
- Django unique model fields validation in form
- Merge/join lists of dictionaries based on a common value in Python
- Rake:task equivalent in Django
- How to disable resize textarea in django?
- Django celery worker to send real-time status and result messages to front end
Source:stackexchange.com