[Answer]-Django related_name in Models

1đź‘Ť

âś…

You can’t call both the recursive relationship on Category and the FK from SubCategory to Category “children”. Pick a different name for one of them.

I must say, though, that this doesn’t seem like a good fit for MPTT at all. Companies don’t fall into a tree relationship, as they are presumably all on the same level, and neither do soda types: what would it mean for “cola” to be a child of “sparkling water”, for example? Sounds like you want a simple ManyToMany relationship from Company to SodaType, so that each company can have many soda types and each type can be made by several companies.

Leave a comment