[Answered ]-Django self referencing model filter ForeignKey

2👍

Use ForeignKey.limit_choices_to – see documentation here

You haven’t provided enough of a code snippet to see how that would be done in your case, but I’m guessing on the parent ForeignKey, you’d want to limit the choices to a lambda function that checks to see if the name of the category is the same as the one doing the referencing.

You probably want a lambda function here, not a single expression.

Leave a comment