Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

django_select2 Caught NameError while rendering: name 'patterns' is not defined

Tags:

django

I am using django_select2 with my mezzanine project.
As per doc i follow processes.

#step1 :
pip install django-select2
#Step2 :
url(r'^select2/', include('django_select2.urls')),

But when i reloaded my website i got error

TemplateSyntaxError at /admin/cms_shop/deliverymethod/200/

Caught NameError while rendering: name 'patterns' is not defined

Request Method:     GET
Request URL:    https://example.net/admin/cms_shop/deliverymethod/200/
Django Version:     1.3.1
Exception Type:     TemplateSyntaxError
Exception Value:    

Caught NameError while rendering: name 'patterns' is not defined

Exception Location:     /home/django/cmsenv/lib/python2.6/site-packages/django_select2/urls.py in , line 5
Python Executable:  /home/django/cmsenv/bin/python
Python Version:     2.6.5
Python Path:    

['/home/django/core/python/cmsintegration',
 '/home/django/cmsenv/lib/python2.6/site-packages/distribute-0.6.14-py2.6.egg',
 '/home/django/cmsenv/lib/python2.6/site-packages/pip-0.8.3-py2.6.egg',
 '/home/django/cmsenv/lib/python2.6/site-packages/paython-0.0.1-py2.6.egg',
 '/home/django/cmsenv/lib/python2.6/site-packages/django_shop-0.0.11.dev0-py2.6.egg',
 '/home/django/cmsenv/lib/python2.6/site-packages/django_recaptcha-0.0.6-py2.6.egg',
 '/home/django/cmsenv/lib/python2.6',
 '/home/django/cmsenv/lib/python2.6/plat-linux2',
 '/home/django/cmsenv/lib/python2.6/lib-tk',
 '/home/django/cmsenv/lib/python2.6/lib-old',
 '/home/django/cmsenv/lib/python2.6/lib-dynload',
 '/usr/lib/python2.6',
 '/usr/lib/python2.6/plat-linux2',
 '/usr/lib/python2.6/lib-tk',
 '/home/django/cmsenv/lib/python2.6/site-packages',
 '/home/django/cmsenv/lib/python2.6/site-packages/PIL']

Please help me what i am doing wrong. my urls.py code is

from django.conf.urls.defaults import *
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns("",
    url(r'^admin/cms_shop/productimport/delete_selected/([\w]+)/$', delete_selected_import_view, name="cms_shop_delete_selected_import"),
    url("^admin/", include(admin.site.urls)),
    url(r'^select2/', include('django_select2.urls')), 
)

in settting.py

INSTALLED_APPS = (
    "django.contrib.admin",
    "django.contrib.auth",
    "django.contrib.contenttypes",
    "django.contrib.redirects",
    "django.contrib.sessions",
    "django.contrib.sites",
    "django.contrib.sitemaps",
    "mezzanine.conf",
    "mezzanine.core",
    "mezzanine.blog",
    "mezzanine.pages",
    "mezzanine.generic",
    "userapp",
    "django_select2",
)
like image 331
Prashant Gaur Avatar asked Nov 30 '22 12:11

Prashant Gaur


2 Answers

FYI, you have Django 1.3 and should consider upgrading to 1.5.

Have you tried

from django.conf.urls import patterns
like image 183
Paul Draper Avatar answered Dec 06 '22 22:12

Paul Draper


You'll get this error if you are upgrading to Django 1.8 or above.

Here is the new way to do it without patterns:

https://docs.djangoproject.com/ja/1.9/releases/1.8/#s-django-conf-urls-patterns

urlpatterns = [
    url('^$', views.myview),
    url('^other/$', views.otherview),
]
like image 45
user984003 Avatar answered Dec 06 '22 21:12

user984003