I
I
Ilya Demyanov2015-11-24 15:30:23
Django
Ilya Demyanov, 2015-11-24 15:30:23

Is there a way to combine TreeForeignKey and ChainedForeignKey?

Let's say we have a model like this:

class Subdivision(MPTTModel):
    subdivision = models.CharField(verbose_name="subdivision", max_length=255)
    affiliate = models.ForeignKey(Group)
    parent = TreeForeignKey("self", null=True, blank=True, related_name="childrens")

How to make it so that, including in the admin panel, it was impossible to select a parent outside the affiliate, i.e. like if the parent field was like a ChainedForeignKey tied to an affiliate?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
marazmiki, 2015-11-24
@marazmiki

Through clean () models will not work?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question