Django-MPTT,如何
嘿,我刚刚安装了 django-mptt 库,但我不知道如何让它工作:(
我已经添加了
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')
它,它工作正常
-
但是当我转到我网站的 Django 管理页面时,我收到错误:
位于 /admin/search/category/admin/mptt_change_list.html
TemplateDoesNotExist
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
谷歌搜索这个错误消息把我带到了这里。
在我的例子中,解决方案是简单地将“mptt”添加到 INSTALLED_APPS 中,以便模板加载器找到 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
pip install django-mptt --upgrade
为我解决了这个问题。这里有一个关于此的已关闭问题: https://github.com/django- mptt/django-mptt/issues/23pip install django-mptt --upgrade
solved the problem for me. There is a closed issue about this here: https://github.com/django-mptt/django-mptt/issues/23使用 easy_install 安装 mptt 时遇到同样的问题。必须强制解压:
easy_install --always-unzip django-mptt-0.5.5.tar.gz
Had the same problem whith mptt installed with easy_install. Had to force unzipping:
easy_install --always-unzip django-mptt-0.5.5.tar.gz
我设法得到同样的错误(0.5.5)。您还必须将“django_mptt_admin”添加到 INSTALLED_APPS。
菲利普.
I managed to get the same error (0.5.5). You also have to add 'django_mptt_admin' to INSTALLED_APPS.
Phillip.
在Django 1.4的settings.py中,TEMPLATE_LOADERS默认将eggs.Loader注释掉。
取消注释 Eggs.Loader 可以找到存储的四个管理模板
。
In settings.py from Django 1.4, TEMPLATE_LOADERS had eggs.Loader commented out by default.
Uncommenting eggs.Loader allowed the four admin templates stored in
to be found.