Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TemplateDoesNotExist error for a simple ModelAdmin example

Tags:

wagtail

I've used Wagtail's ModelAdmin on a few other projects with great success, but this is the first time I'm attempting to use it with a model inheriting from Page.

I copied the simple example template and removed the parts that didn't relate to my BlogPageModel.

The link to the ModelAdmin appears as expected, but when I click it, I get TemplateDoesNotExist at /admin/blog/blogpage/.

I don't remember having to set up a template before. Is there a setting I'm missing?

Wagtail: 1.9 / Django: 1.10.5 / Python: 3.5.2

Update: I tried it with a model that inherits from models.Model as well with the same result.

Traceback follows:

Internal Server Error: /admin/blog/blogpage/
Traceback (most recent call last):
  File "/Users/username/.virtualenv/lib/python3.5/site-packages/django/core/handlers/exception.py", line 39, in inner
    response = get_response(request)
  File "/Users/username/.virtualenv/lib/python3.5/site-packages/django/core/handlers/base.py", line 249, in _legacy_get_response
    response = self._get_response(request)
  File "/Users/username/.virtualenv/lib/python3.5/site-packages/django/core/handlers/base.py", line 217, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/Users/username/.virtualenv/lib/python3.5/site-packages/django/core/handlers/base.py", line 215, in _get_response
    response = response.render()
  File "/Users/username/.virtualenv/lib/python3.5/site-packages/django/template/response.py", line 109, in render
    self.content = self.rendered_content
  File "/Users/username/.virtualenv/lib/python3.5/site-packages/django/template/response.py", line 84, in rendered_content
    template = self.resolve_template(self.template_name)
  File "/Users/username/.virtualenv/lib/python3.5/site-packages/django/template/response.py", line 66, in resolve_template
    return select_template(template, using=self.using)
  File "/Users/username/.virtualenv/lib/python3.5/site-packages/django/template/loader.py", line 53, in select_template
    raise TemplateDoesNotExist(', '.join(template_name_list), chain=chain)
django.template.exceptions.TemplateDoesNotExist: modeladmin/blog/blogpage/index.html, modeladmin/blog/index.html, modeladmin/index.html
[21/Feb/2017 07:56:38] "GET /admin/blog/blogpage/ HTTP/1.1" 500 110901
like image 433
Chris May Avatar asked Feb 20 '17 22:02

Chris May


People also ask

How do I fix TemplateDoesNotExist error?

Django TemplateDoesNotExist error means simply that the framework can't find the template file. To use the template-loading API, you'll need to tell the framework where you store your templates. The place to do this is in your settings file ( settings.py ) by TEMPLATE_DIRS setting.

How do I fix template errors in Django?

Confirm if Django is looking for templates in app directories. For this you need to see templates setting in settings.py file. Check if APP_DIR is set to True . If this is set to False , Django won't look for templates in app directories.


1 Answers

I suspect you've missed out adding 'wagtail.contrib.modeladmin' to INSTALLED_APPS.

like image 116
gasman Avatar answered Nov 14 '22 03:11

gasman