﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
25505	Incomplete relation_tree for inherited proxied Models.	Jelko Arnds	nobody	"`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."	Bug	closed	Database layer (models, ORM)	1.8	Normal	fixed	models, meta, deletion, relation, inheritance	Simon Charette	Accepted	0	0	0	0	0	0
