drf 树菜单返回

"""
            class MPTTMeta:
                order_insertion_by = ['title']
        
            def __unicode__(self): return self.title
        
            def __str__(self): # 循环查找父菜单返回字符串 self-parent-parent
                title_list = [self.title,]
                p = self.parent
                while p:
                    # caption_list.append(p.caption)
                    title_list.insert(0,p.title)
                    p = p.parent
        
                return "-".join(title_list)
        """

猜你喜欢

转载自blog.csdn.net/sinat_33384251/article/details/88545008
DRF