Giter Club home page Giter Club logo

django-apptemplates's People

Contributors

bittner avatar dracos avatar jwalgran avatar krtek4 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

django-apptemplates's Issues

'NoneType' object has no attribute 'get_contents' when using cached Loader

Hi,

I switched to django cached Loader

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [
            os.path.join(BASE_DIR, 'project', 'templates'),
            os.path.join(BASE_DIR, 'templates'),
        ],
        'OPTIONS': {
            'context_processors': [
                ...
            ],
            'loaders': [
                ('django.template.loaders.cached.Loader', [
                    'apptemplates.Loader',
                    ...
                ]),
            ],
        },
    },
]  

and this error occured:

'NoneType' object has no attribute 'get_contents'
Request Method:	GET
Django Version:	1.10.7
Exception Type:	AttributeError
Exception Value:	
'NoneType' object has no attribute 'get_contents'
Exception Location:	/lib/python3.4/site-packages/django/template/loaders/cached.py in get_contents, line 28
Python Executable:	/bin/python
Python Version:	3.4.2

Template error:
In template /project/templates/template.html, error at line 1
   'NoneType' object has no attribute 'get_contents'   1 :  {% extends "core:base_site.html" %} 
   2 : {% load static i18n %}
   3 : 
   4 : {% block content %}
   5 :     <div class="container-fluid article">


Traceback:

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

File "/lib/python3.4/site-packages/django/core/handlers/base.py" in _legacy_get_response
  249.             response = self._get_response(request)

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

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

File "/lib/python3.4/site-packages/django/template/response.py" in render
  109.             self.content = self.rendered_content

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

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

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

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

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

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

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

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

File "/lib/python3.4/site-packages/django/template/loader_tags.py" in find_template
  129.             template_name, skip=history,

File "/lib/python3.4/site-packages/django/template/engine.py" in find_template
  134.                         name, template_dirs=dirs, skip=skip,

File "/lib/python3.4/site-packages/django/template/loaders/cached.py" in get_template
  60.                 template_name, template_dirs, skip,

File "/lib/python3.4/site-packages/django/template/loaders/base.py" in get_template
  38.                 contents = self.get_contents(origin)

File "/lib/python3.4/site-packages/django/template/loaders/cached.py" in get_contents
  28.         return origin.loader.get_contents(origin)

Exception Type: AttributeError at /oprava-microsoft-xbox-360/poskodenie-tekutinou/
Exception Value: 'NoneType' object has no attribute 'get_contents'

Settings KeyError: APP_DIRS must not be set when loaders is defined

Context: Trying to over ride base_site.html when using django-admin-interface package. I have one file in main/templates/admin, which is base_site.html. And have {% extends "admin_interface:admin/base_site.html" %} at top.

KeyError:

"app_dirs must not be set when loaders is defined."
django.core.exceptions.ImproperlyConfigured: app_dirs must not be set when loaders is defined.

settings.py

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [
            os.path.join(BASE_DIR, 'main/templates/admin'), 
            os.path.join(BASE_DIR, 'main/templates/main'), 
        ],
        'APP_DIRS': True,
        'OPTIONS': {
            'loaders':[
                'apptemplates.Loader',
            ],
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

Removing 'APP_DIRS' causes a TEMPLATE DOES NOT EXIST error.

Using django-admin-interface package.

Problems with AppConfig

It seems that if an application is specified via AppConfig, it will not work:

INSTALLED_APPS = (
    'wiki.apps.WikiConfig'
)

For django-wiki, this produces errors like TemplateDoesNotExist: "wiki:wiki/base.html". Other variations like specifying the app config {% extends "wiki.apps.WikiConfig:wiki/base.html" %} aren't working neither.

Specified as just the app, it works:

INSTALLED_APPS = (
    'wiki'
)

I kind of gather from the implementation that it's assumed that the entry of INSTALLED_APPS is importable models and not AppConfig class paths?

https://github.com/bittner/django-apptemplates/blob/master/apptemplates/__init__.py#L18

Order of imports that have moved

Only a tiny thing, but the comment at

try:
from django.test.utils import override_settings
except ImportError: # older Djangos
from django.test import override_settings
implies django.test.utils is the current location, but that is the old location – on https://docs.djangoproject.com/en/1.8/topics/testing/tools/#django.test.override_settings it says: "Changed in Django 1.7: Previously, override_settings was imported from django.test.utils."

I'm not sure why this got swapped round in 623842b#diff-f4bc68ff01eef7bed2f3a64cad7d37ca but the other try import in

try:
from importlib import import_module # noqa pylint: disable=wrong-import-order,no-name-in-module
except ImportError: # Python < 2.7
from django.utils.importlib import import_module # noqa pylint: disable=no-name-in-module,import-error
puts the more recent location first, so I thought this should match. But as I say, only a tiny thing :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.