#14891: use_for_related_fields=False is not honored by reverse FK or M2M related
managers
-------------------------------------+-------------------------------------
Reporter: sdksho@… | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 1.2
(models, ORM) |
Severity: Normal | Resolution:
Keywords: Manager | Triage Stage: Accepted
ManyToManyField |
use_for_related_fields |
Has patch: 1 | Needs documentation: 1
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by jarshwah):
Here's an idea to close out this ticket. Free to anyone that's hurt by
this issue and would like to attempt to fix it.
1) deprecate use_for_related_fields flag on manager
2) remove the documentation for use_for_related_fields
3) implement 'manager="manager_name"' and 'reverse_manager="manager_name"'
on related fields (ware migrations)
4) document the new keyword arguments to ForeignKey/M2MField/OneToOneField
This will give you full control over which managers are used at all times,
while still allowing explicit override: `model.foo_set(manager='other')`
This will be more verbose, but it'll be correct.
{{{
class MyModel(models.Model):
objects = MyDefaultManager()
related = MyRelatedManager()
foo = models.ForeignKey(Foo, manager='objects',
related_manager='related')
}}}
I don't think putting a big warning in the docs "this does not work" is
sufficient, especially when there are definitely avenues for fixing the
underlying problem. It's the lazy way out. Doing nothing is also bad. But
until someone steps up to actually do the work, then it's still going to
be an issue.
Now, does my proposal above have any significant drawbacks? It's a
combination of previous talk and my discussions with Loic on IRC.
--
Ticket URL: <https://code.djangoproject.com/ticket/14891#comment:27>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/076.571c065fca1d74d6a84b57fd0d6b4056%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.