GenericForeignKey always uses a default manager of a related model
|Reported by:||Ivan Virabyan||Owned by:||nobody|
|Cc:||me@…||Triage Stage:||Ready for checkin|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
From Django docs:
By default, Django uses an instance of a "plain" manager class when accessing related objects (i.e. choice.poll), not the default manager on the related object. This is because Django needs to be able to retrieve the related object, even if it would otherwise be filtered out (and hence be inaccessible) by the default manager.
This is true for ForeignKey, but not GenericForeignKey. So I have no ability to use custom managers for my models, because they are being filtered when I'm accessing related objects.
Change History (8)
comment:2 Changed 6 years ago by
|Owner:||changed from Andy Durdin to nobody|
|Status:||assigned → new|
|Triage Stage:||Unreviewed → Accepted|