我已经为 Django 安装了 MPTT,把它放在“已安装的应用程序”中,设置我的文件,并同步我的数据库。我的模型显示在管理员中,但是当我尝试添加类别后单击保存时,我收到以下错误:
DatabaseError at /admin/myapp/category/add/
relation "django_admin_log" does not exist
LINE 1: INSERT INTO "django_admin_log" ("action_time", "user_id", "c...
这是我的文件:
楷模:
from django.db import models
from django.contrib.auth.models import User
from mptt.models import MPTTModel, TreeForeignKey
class Category(MPTTModel):
user = models.ForeignKey(User)
name = models.CharField(max_length=30, unique=True)
parent = TreeForeignKey('self', null=True, blank=True, related_name='children')
class MPTTMeta:
order_insertion_by = ['name']
def __unicode__(self):
return self.name
行政:
from django.contrib import admin
from myapp.models import Category
from mptt.admin import MPTTModelAdmin
admin.site.register(Category, MPTTModelAdmin)