2

I work with Django 1.8 and I instaled django-localurl==2.0.2.

I loaded localurl tag {% load localeurl_tags %} in my base.html template, and I get an error:

TemplateSyntaxError at /

'localeurl_tags' is not a valid tag library: ImportError raised loading localeurl.templatetags.localeurl_tags: cannot import name Token

How can I fix it?

My settings.py

MIDDLEWARE_CLASSES = (
    'django.contrib.sessions.middleware.SessionMiddleware',
    'localeurl.middleware.LocaleURLMiddleware',
    '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.middleware.security.SecurityMiddleware',
)

My urls:

urlpatterns = patterns('',
    # Examples:
    # url(r'^$', 'website.views.home', name='home'),
    # url(r'^blog/', include('blog.urls')),
    (r'^i18n/', include('django.conf.urls.i18n')),
    url(r'', include("www.urls", namespace="www")),
    url(r'^blog/', include("blog.urls", namespace="blog")),
    url(r'^admin/', include(admin.site.urls)),
    url(r'^ckeditor/', include('ckeditor.urls')),
    (r'^localeurl/', include('localeurl.urls')),
)

Yes, I have 'localeurl' in Instated apps

mark
  • 653
  • 1
  • 10
  • 23

1 Answers1

0

It appears that localeurl is no longer maintained because (from here):

NOTE: django-localeurl is currently un-maintained (so pull requests will not be reviewed or merged), and its approach has been obsoleted by the introduction of locale-aware URL patterns in Django itself (https://docs.djangoproject.com/en/1.8/topics/i18n/translation/#module-django.conf.urls.i18n).

So I'd have a look at the builtin way, because the error message (upon further reading) seems to suggest that the Token class in django.templates no longer exists (likely got taken out in 1.8 or something).

Have you followed the instructions here?

  1. Have you added 'localeurl.middleware.LocaleURLMiddleware' to your middleware?

  2. Have you added 'localeurl' to your installed apps?

CrazyCasta
  • 26,917
  • 4
  • 45
  • 72