本文介绍了Django-MPTT,怎么样的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗯,我刚刚安装了django-mptt lib,但是我不知道如何使它工作:(我添加了
class类别(MPTTModel)
$ (max_length = 200,unique = True)
name = models.CharField(max_length = 100)
parent = models.ForeignKey('self',blank = True,null = True,related_name ='child' )
这样做很好
但是当我转到我网站的Django Admin页面时,我收到一个错误:
TemplateDoesNotExist at / admin / search / category /
admin / mptt_change_list.html
解决方案
Google搜索这个错误信息让我来到这里。
在我的情况下,解决方案是简单地添加mptt到INSTALLED_APPS的模板加载器来查找admin / mptt_change_list.html
Hey, I have just installed the django-mptt lib, but i don't know how to get it to work :(
I have added
from mptt.models import MPTTModel
class Category(MPTTModel):
slug = models.SlugField(max_length=200, unique=True)
name = models.CharField(max_length=100)
parent = models.ForeignKey('self', blank=True, null=True, related_name='child')
It that works fine
-
But when i go to the Django Admin page of my site i got an error:
TemplateDoesNotExist at /admin/search/category/
admin/mptt_change_list.html
解决方案
Googling this error message brought me here.
In my case solution was to simply add 'mptt' to INSTALLED_APPS for template loader to find admin/mptt_change_list.html
这篇关于Django-MPTT,怎么样的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!