0
book_category_list=[]
for book_category in BookCategory.objects.filter(parent__isnull = True):
    book_category_list.append(book_category.get_family())**

now the book_category_list in tree query set format. I need to list categories in a tree structure. So I need to convert this book_category_list into dictionary format. BookCategory is an MPTT Model?

enes islam
  • 1,054
  • 4
  • 12
Rahman
  • 1
  • You should share your models and usage of the piece of code you have added here. – ruddra Oct 06 '22 at 11:46
  • class BookCategory(MPTTModel): title=models.CharField(max_length=100,unique=True) code = models.CharField(max_length=300,blank=True) path = models.TextField() parent = TreeForeignKey('self',null=True,blank=True,db_index=True,on_delete=models.CASCADE,related_name='childrens') – Rahman Oct 06 '22 at 11:50

0 Answers0