#25505: Incomplete relation_tree for inherited proxied Models. -------------------------------------+------------------------------------- Reporter: jelko | Owner: nobody Type: Bug | Status: new Component: Database layer | Version: 1.8 (models, ORM) | Keywords: models, meta, deletion, Severity: Normal | relation, inheritance Triage Stage: Unreviewed | Has patch: 0 Easy pickings: 0 | UI/UX: 0 -------------------------------------+------------------------------------- `Options._populate_directed_relation_graph` produces an incomplete `Options._relation_tree` for Models that have set `Meta.Proxy = True`.
Consider this setup: BaseModel(models.Model) -> ProxyModel(BaseModel) [with Proxy = True] -> ChildModel(ProxyModel) In this case the OneToOne relation from ProxyModel to ChildModel is not included in the proxymodel's `_meta._relation_tree`. This is caused because `Options._populate_directed_relation_graph` collects the relations by calling `model._meta._get_fields(reverse=False, include_parents=False)`. Therefore the parent, in this case the ProxyModel is not included. This results in some unwanted situations. If you call `delete()` on a ProxyModel, the BaseModel gets deleted, but the ChildModel instance stays in the database and becomes orphaned. Have a look at the attached models.py to replicate the setup. Compare the behavior of `delete()` for instances of `ChipShop` and `IndianRestaurant`, to see the problem. -- Ticket URL: <https://code.djangoproject.com/ticket/25505> 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 django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/048.b298c8b9e25e467ff8e0c0b12a363df1%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.