jazzband / django-dbtemplates

Django template loader for database stored templates with extensible cache backend
https://django-dbtemplates.readthedocs.io
Other
253 stars 154 forks source link

ExtendsError at /admin/ Cannot extend templates recursively when using non-recursive template loaders #90

Open m-vdb opened 6 years ago

m-vdb commented 6 years ago

I get this error when I want to extend my admin/base.html template. It works properly when dbtemplates.loader.Loader is not in the TEMPLATES settings, but when it is (even if I try to load a template that is not from the database), I get this error:

Environment:

Request Method: GET
Request URL: http://localhost:8000/admin/

Django Version: 1.11.5
Python Version: 3.6.3
Installed Applications:
['myproject',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.sites',
 'collectfaster',
 'django.contrib.staticfiles',
 'django.contrib.humanize',
 'jet',
 'django.contrib.admin',
 'smuggler',
 'raven.contrib.django.raven_compat',
 'rest_framework',
 'rest_framework.authtoken',
 'corsheaders',
 'colorfield',
 'dbtemplates',
 'django_premailer',
 'algoliasearch_django',
 'push_notifications',
 'schedule',
 'django_filters',
 'django_user_agents']
Installed Middleware:
['raven.contrib.django.middleware.SentryMiddleware',
 'django.middleware.security.SecurityMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'corsheaders.middleware.CorsMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'django_user_agents.middleware.UserAgentMiddleware']

Template error:
In template /myproject/templates/admin/base.html, error at line 1
   Cannot extend templates recursively when using non-recursive template loaders   1 :  {% extends "admin/base.html" %} 
   2 : 
   3 : 
   4 : {% block content %}
   5 :
   6 : {{ block.super }}

Traceback:

File "/myproject/lib/python3.6/site-packages/django/core/handlers/exception.py" in inner
  41.             response = get_response(request)

File "/myproject/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
  217.                 response = self.process_exception_by_middleware(e, request)

File "/myproject/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
  215.                 response = response.render()

File "/myproject/lib/python3.6/site-packages/django/template/response.py" in render
  107.             self.content = self.rendered_content

File "/myproject/lib/python3.6/site-packages/django/template/response.py" in rendered_content
  84.         content = template.render(context, self._request)

File "/myproject/lib/python3.6/site-packages/django/template/backends/django.py" in render
  66.             return self.template.render(context)

File "/myproject/lib/python3.6/site-packages/django/template/base.py" in render
  207.                     return self._render(context)

File "/myproject/lib/python3.6/site-packages/django/template/base.py" in _render
  199.         return self.nodelist.render(context)

File "/myproject/lib/python3.6/site-packages/django/template/base.py" in render
  990.                 bit = node.render_annotated(context)

File "/myproject/lib/python3.6/site-packages/django/template/base.py" in render_annotated
  957.             return self.render(context)

File "/myproject/lib/python3.6/site-packages/django/template/loader_tags.py" in render
  177.             return compiled_parent._render(context)

File "/myproject/lib/python3.6/site-packages/django/template/base.py" in _render
  199.         return self.nodelist.render(context)

File "/myproject/lib/python3.6/site-packages/django/template/base.py" in render
  990.                 bit = node.render_annotated(context)

File "/myproject/lib/python3.6/site-packages/django/template/base.py" in render_annotated
  957.             return self.render(context)

File "/myproject/lib/python3.6/site-packages/django/template/loader_tags.py" in render
  177.             return compiled_parent._render(context)

File "/myproject/lib/python3.6/site-packages/django/template/base.py" in _render
  199.         return self.nodelist.render(context)

File "/myproject/lib/python3.6/site-packages/django/template/base.py" in render
  990.                 bit = node.render_annotated(context)

File "/myproject/lib/python3.6/site-packages/django/template/base.py" in render_annotated
  957.             return self.render(context)

File "/myproject/lib/python3.6/site-packages/django/template/loader_tags.py" in render
  154.         compiled_parent = self.get_parent(context)

File "/myproject/lib/python3.6/site-packages/django/template/loader_tags.py" in get_parent
  151.         return self.find_template(parent, context)

File "/myproject/lib/python3.6/site-packages/django/template/loader_tags.py" in find_template
  120.                         "Cannot extend templates recursively when using "

Exception Type: ExtendsError at /admin/
Exception Value: Cannot extend templates recursively when using non-recursive template loaders

I am not familiar with template loaders but I can help if needed. I think the issue comes from these lines. And to enable this parameter the get_contents() method on the loader needs to be implemented (as per this).

LMK if I can help more.

m-vdb commented 6 years ago

Oh I see that it is tackled in #87. How can I help?

mpasternak commented 2 years ago

Is this problem still applicable?