1 2 3 4 5 6 7 8 9 | from django.db.models.deletion import Collector
from django.db import router
from myapp.models import MyModel
def get_related(queryset):
using = router.db_for_read(queryset.model)
coll = Collector(using=using)
coll.collect(queryset)
return coll.data
|
More like this
- Bitwise operator queryset filter by hgeerts@osso.nl 3 years ago
- ParentModel and ChildManager for Model Inheritance by jpwatts 4 years, 8 months ago
- Modifying the fields of a third/existing model class by marinho 2 years, 4 months ago
- Signal to post new saved objects to Twitter by arthurfurlan 4 years, 2 months ago
- A ModelChoiceField with support for title in options based on a field in the model by celopes 2 years, 9 months ago
Comments