开发者

Django-MPTT, how to

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


pip 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


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


I managed to get the same error (0.5.5). You also have to add 'django_mptt_admin' to INSTALLED_APPS.

Phillip.


In settings.py from Django 1.4, TEMPLATE_LOADERS had eggs.Loader commented out by default.

TEMPLATE_LOADERS = (
    'django.template.loaders.filesystem.Loader',
    'django.template.loaders.app_directories.Loader',
  # 'django.template.loaders.eggs.Loader',
)

Uncommenting eggs.Loader allowed the four admin templates stored in

python/virtenv/lib/python2.7/site-packages/django_mptt-0.7.4-py2.7.egg

to be found.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜