【发布时间】:2020-12-06 13:44:44
【问题描述】:
我想在 Django 中的类别和子类别中进行导航。
我安装了 django-mptt,现在我得到了这个错误。“类型对象 'Category' 没有属性 '_mptt_meta'”
models.py
from mptt.models import MPTTModel, TreeForeignKey
# Create your models here.
class Category(models.Model):
name=models.CharField(max_length=50)
slug=models.SlugField(max_length=50, unique=True, help_text='Uniue Value product page url, created from name.')
is_active=models.BooleanField(default=True)
created_at=models.DateTimeField(auto_now_add=True)
updated_at=models.DateTimeField(auto_now=True)
parent=TreeForeignKey('self',on_delete=models.CASCADE,null=True,blank=True, related_name='children')
class MPTTMeta:
order_insertion_by=['name']
先谢谢了。
【问题讨论】:
标签: python python-3.x django django-models django-views