Answer the question
In order to leave comments, you need to log in
How to make a directory with a large level of nesting of categories?
Hello everyone
. Such a question, but how to make a directory in Django with nesting of subcategories by 4-5 levels? I usually made a field with a category selection, but how to nest categories?
Answer the question
In order to leave comments, you need to log in
You can add a parent field to the category, which will refer to the category class itself:
class Category(models.Model):
...
parent = models.ForeignKey('self', blank=True, null=True, verbose_name="Родитель", related_name='children')
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question