#18012: Propagate reverse foreign keys from proxy models to base class
-------------------------------------+-------------------------------------
     Reporter:  akaariai             |                    Owner:  charettes
         Type:                       |                   Status:  assigned
  Cleanup/optimization               |
    Component:  Database layer       |                  Version:  1.4
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by akaariai):

 My example wasn't that great, sorry for that.

 What I'm after is that if we add proxy relations to the parent models we
 don't break anything (except for backwards incompatibility in the Meta
 API). The same isn't true for MTI inheritance, where a lot would break if
 we added child model relations to parent models.

 We do support an inheritance chain of Concrete -> ProxyConcrete ->
 ProxyConcreteChild. Interestingly this chain actually creates a foreign
 key from ProxyConcreteChild directly to Concrete in the model definition.
 This is inconsistent, the foreign key should be to ProxyConcrete. But we
 can't do that, as then
 Concrete.objects.select_related('proxyconcretechild') wouldn't work, as
 Concrete doesn't have the reverse descriptor for the relation from
 ProxyConcreteChild to ProxyConcrete.

 Also, my reverse_queryset example is broken. This assumes you want to get
 the *reverse* relation as proxy instances, whereas the foreign key to
 proxy feature is about getting the *direct* relation as proxy instances.
 While maybe an useful feature, it doesn't change anything for this ticket.
 Instead we should have fk = models.ForeignKey(ConcreteModel,
 fetch_as=ProxyModel) or something like that. This might actually make some
 sense if done automatically. The user writes ForeignKey(ProxyModel),
 internally Django interprets it as ForeignKey(ConcreteModel,
 fetch_as=ProxyModel). But I guess we do have more important problems to
 solve.

 Even if I see a slight advantage in publishing reverse relations to
 concrete parents, I guess I'm slightly in favor of closing this one and
 moving on to something more productive.

--
Ticket URL: <https://code.djangoproject.com/ticket/18012#comment:16>
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/066.a8be78e47935c7edc68c46fd9f916531%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to