django_select2 Caught NameError while rendering: name 'patterns' is not defined - 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",
)

FYI, you have Django 1.3 and should consider upgrading to 1.5.
Have you tried
from django.conf.urls import patterns

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),
]

Related

from django.urls import ( # noqa ModuleNotFoundError: No module named 'django.urls' [duplicate]

I'm using django==1.8, rest_framework=3.7.7, python==2.7.12
urls.py
urlpatterns += [
url(r'^api/core/', include('core.urls')),
]
core/urls.py
urlpatterns=[
url(r'^/users/', core_view.userlist),
]
views.py
class UserList(generics.ListAPIView):
queryset = User.objects.all()
serializer_class = UserSerializer
userlist = UserList.as_view()
When I'm navagating to: http://localhost:8000/api/core/users I'm getting the following error:
ImportError at /api/core/users
No module named urls
Request Method: GET
Request URL: http://localhost:8000/api/core/users
Django Version: 1.8
Exception Type: ImportError
Exception Value:
No module named urls
Exception Location: /usr/local/lib/python2.7/dist-packages/rest_framework/compat.py in <module>, line 26
Python Executable: /usr/bin/python
Python Version: 2.7.12
what is wrong in configuration?
Django Rest Framework dropped support for Django 1.8 in version 3.7.
You should install an earlier version of rest framework, or upgrade Django (note that Django 1.8 reaches end-of-life in April 2018)
Just Make sure you include core app in your INSTALLED_APPS settings, and that you have init.py in your core directory folder.
Look here for more information.

Error updating django 1.5 - u "'admin' is not a registered namespace

I am upgrading django from 1.4 to 1.5 in the front and all goes well, but admin side when I try to enter the url I get this particular error, and not how to fix it, any ideas?
error:
NoReverseMatch at /admin/
u"'admin" is not a registered namespace
Request Method: GET
Request URL: http://lmgsyco.com/admin/
Django Version: 1.4.1
Exception Type: NoReverseMatch
Exception Value:
u"'admin" is not a registered namespace
Exception Location: /usr/local/lib/python2.6/dist-packages/django/template/defaulttags.py in render, line 424
Python Executable: /usr/bin/python
Python Version: 2.6.6
Urls:
from django.conf.urls.defaults import *
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
url(r'^$', web_page, name='web_page'),
url(r'^login/$', 'django.contrib.auth.views.login'),
url(r'^logout/$', cerrar_sesion, name='cerrar_sesion'),
# Admin:
url(r'^admin/', include(admin.site.urls)),
# Admin documentation:
# url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
)
I had a problem that seems related to this.
Your error is showing Django 1.4.1, while from your question you seem to be trying to use 1.5.
Check your PYTHONPATH with
env | grep PYTHONPATH
My guess is that you are pointing to the old version of Django somewhere. (In my case it was my .bashrc file. I had set up virtualenv to use Django 1.5, but .bashrc was pointing it to 1.4 , and this was getting put in first in the PYTHONPATH).

Django on GAE - name 'url' is not defined

I've just uploaded my django web app to GAE, but I'm getting an error when I compile it with "dev_appserver.py":
Exception Type: NameError
Exception Value: name 'url' is not defined
Here my urls.py:
from django.conf.urls.defaults import *
urlpatterns = patterns(
'',
url(r'^landing/$', 'webpage_dev.dashboard.views.landing'),
)
I'm importing url from django.conf.urls.default. Why appear this error?
Thanks a lot
from django.conf.urls.defaults import patterns, url

cannot import name admin

I am new at Django. I am trying to create basic admin panel. when I changed the urls.py file and I put url(r'^admin/', include(admin.site.urls)), into patterns then it gave error like that:
Request Method: GET return
Request URL: http://127.0.0.1:8000/
Django Version: 1.4
Exception Type: ImportError
Exception Value:cannot import name admin
Exception Location:/home/ulascan/Desktop/projects/purple/purple/urls.py in <module>, line 1
Python Executable: /usr/bin/python
Python Version: 2.7.3
Python Path:
['/home/ulascan/Desktop/projects/purple',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-linux2'
...
...]
Make sure that in your settings.py you have django.contrib.admin, uncommented in INSTALLED_APPS. And also check that you have these lines in your urls.py:
from django.contrib import admin
admin.autodiscover()

DJANGO RESTAPI--No module found error

I downloaded the code from the following link and stored it in the location below,
http://django-rest-interface.googlecode.com/svn/trunk/ django-rest-interface
Location
c:/Python27/Djangoprojects/django_restapi
Project Location
c:/Python27/Djangoprojects/mysite/polls
URLS.py
from django.conf.urls.defaults import *
from polls.views import *
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
(r'^polls/$',index),
(r'^polls/(?P<poll_id>\d+)/$',detail),
(r'^polls/(?P<poll_id>\d+)/results/$',results),
(r'^polls/(?P<poll_id>\d+)/vote/$',vote),
(r'^admin/', include(admin.site.urls)),
(r'^xml/polls/(.*?)/?$',xml_poll_resource),
)
views.py
from django_restapi.model_resource import Collection
from django_restapi.responder import XMLResponder
from django_restapi.responder import *
from django_restapi_tests.polls.models import Poll, Choice
xml_poll_resource = Collection(
queryset = Poll.objects.all(),
permitted_methods = ('GET', 'POST', 'PUT', 'DELETE'),
responder = XMLResponder(paginate_by = 10)
)
I get the following error when I try the URL specified below,
Error:
ImportError at /xml/polls/
No module named django_restapi.model_resource
Request Method:
GET
Request URL:
http://127.0.0.1:8000/xml/polls/
Django Version:
1.3.1
Exception Type:
ImportError
Exception Value:
No module named django_restapi.model_resource
Exception Location:
C:\Python27\Djangoprojects\mysite..\mysite\polls\views.py in , line 1
Python Executable:
C:\Python27\python.exe
Python Version:
2.7.2
Python Path:
['C:\Python27\Djangoprojects\mysite',
'C:\Python27\lib\site-packages\setuptools-0.6c11-py2.7.egg',
'C:\Python27\lib\site-packages\django_db_log-2.2.1-py2.7.egg',
'C:\Python27',
'c:\Python27\lib\site-packages\django\bin\django-admin.py',
'c:\mysql',
'c:\pythonpath\djangoprojects\django_restapi',
'C:\Windows\system32\python27.zip',
'C:\Python27\DLLs',
'C:\Python27\lib',
'C:\Python27\lib\plat-win',
'C:\Python27\lib\lib-tk',
'C:\Python27\lib\site-packages',
'C:\Python27\lib\site-packages\wx-2.8-msw-unicode']
Server time:
Thu, 12 Jul 2012 22:31:04 -0400
How do I resolver this error?
As from your code, Polls directory should be inside django_restapi and you should put parent of django_restapi in python path.
Did you check the setting.py file?