Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange error after update to 1.3.3 #121

Closed
BooBSD opened this issue Apr 21, 2015 · 4 comments
Closed

Strange error after update to 1.3.3 #121

BooBSD opened this issue Apr 21, 2015 · 4 comments

Comments

@BooBSD
Copy link

BooBSD commented Apr 21, 2015

After update from 1.3.2 to 1.3.3 I found out an error:

Environment:


Request Method: GET
Request URL: http://127.0.0.1:8000/

Django Version: 1.8
Python Version: 2.7.9
Installed Applications:
('django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.sites',
 'django.contrib.sitemaps',
 'pipeline',
 'django_jinja',
 'thumbnailfield',
 'apps.core',
 'apps.recipes')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
 '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',
 'apps.core.middleware.MobileDetectMiddleware')


Traceback:
File "/home/boo/projects/venvs/recipes/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
  132.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/boo/projects/recipes/website/apps/recipes/views.py" in home
  7.     return render(request, 'home.jinja', {'categories': Recipe.CATEGORIES})
File "/home/boo/projects/venvs/recipes/lib/python2.7/site-packages/django/shortcuts.py" in render
  67.             template_name, context, request=request, using=using)
File "/home/boo/projects/venvs/recipes/lib/python2.7/site-packages/django/template/loader.py" in render_to_string
  98.             template = get_template(template_name, using=using)
File "/home/boo/projects/venvs/recipes/lib/python2.7/site-packages/django/template/loader.py" in get_template
  42.                 return engine.get_template(template_name)
File "/home/boo/projects/venvs/recipes/lib/python2.7/site-packages/django_jinja/backend.py" in get_template
  142.         if not self.match_template(template_name):
File "/home/boo/projects/venvs/recipes/lib/python2.7/site-packages/django_jinja/backend.py" in match_template
  139.                                    extension=self._match_extension)
File "/home/boo/projects/venvs/recipes/lib/python2.7/site-packages/django_jinja/base.py" in match_template
  256.             return matches_extension and re.match(regex, template_name)
File "/home/boo/projects/venvs/recipes/lib/python2.7/re.py" in match
  141.     return _compile(pattern, flags).match(string)
File "/home/boo/projects/venvs/recipes/lib/python2.7/re.py" in _compile
  251.         raise error, v # invalid expression

Exception Type: error at /
Exception Value: nothing to repeat

@niwinz
Copy link
Owner

niwinz commented Apr 29, 2015

Can you give me your configuration, it seems related to how you have configured the backend.

@BooBSD
Copy link
Author

BooBSD commented May 2, 2015

Sure, here it is:

import os
BASE_DIR = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
rel = lambda pth: os.path.join(BASE_DIR, pth)

TEMPLATES = [
    {
        'BACKEND': 'django_jinja.backend.Jinja2',
        'APP_DIRS': True,
        'DIRS': [rel('templates')],
        'OPTIONS': {
            'match_extension': '.jinja',
            'match_regex': '*\.jinja$', # This is exclusive with "match_extension"
            'newstyle_gettext': True,
            'extensions': [
                'jinja2.ext.do',
                'jinja2.ext.loopcontrols',
                'jinja2.ext.with_',
                'jinja2.ext.i18n',
                'jinja2.ext.autoescape',
                'django_jinja.builtins.extensions.CsrfExtension',
                'django_jinja.builtins.extensions.CacheExtension',
                'django_jinja.builtins.extensions.TimezoneExtension',
                'django_jinja.builtins.extensions.UrlsExtension',
                'django_jinja.builtins.extensions.StaticFilesExtension',
                'django_jinja.builtins.extensions.DjangoFiltersExtension',
                'pipeline.jinja2.ext.PipelineExtension',
            ],
            'context_processors': [
                'django.core.context_processors.media',
                'django.core.context_processors.static',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
                'apps.recipes.context_processors.custom_context'
            ],
            'autoescape': True,
            'auto_reload': DEBUG,
            'translation_engine': 'django.utils.translation',
        }
    },
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [rel('templates')],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.core.context_processors.media',
                'django.core.context_processors.static',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages'
            ],
        }
    }
]

@niwinz
Copy link
Owner

niwinz commented May 25, 2015

I can not reproduce it. Are you checked that with the last version of django_jinja ?

PS: you have both match_regex and match_extension in settings that are completelly redundant, keep the extension and remove the regex based.

@niwinz
Copy link
Owner

niwinz commented May 25, 2015

Ah, ok, that should work with the last version because some related errors to regex are fixed.

@niwinz niwinz closed this as completed May 25, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants