Opened 10 years ago
Closed 10 years ago
#26127 closed Bug (duplicate)
ReverseManyToOneDescriptor doesn't respect use_for_related_fields attribute
| Reported by: | Robert Robinson | Owned by: | nobody |
|---|---|---|---|
| Component: | Database layer (models, ORM) | Version: | 1.9 |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
The other two descriptors respect the flag and will use the _base_manager if the manager has use_for_related_fields set to false. The ReverseManyToOneDescriptor always uses the _default_manager regardless of whether it is supposed to or not.
def related_manager_cls(self):
return create_reverse_many_to_one_manager(
self.rel.related_model._default_manager.__class__,
self.rel,
)
Or am I misunderstanding:
If this attribute is set on the default manager for a model (only the default manager is considered in these situations), Django will use that class whenever it needs to automatically create a manager for the class. Otherwise, it will use django.db.models.Manager.
Duplicate of #14891 I believe.