Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImportError: cannot import name patterns

Tags:

python

django

Python Version: 2.7.5

Django Version: 1.10

When I type nohup python manage.py runserver 0.0.0.0:9001 it shows me

enter image description here

I have googled and someone told me to vi urls.py, but it doesn't work. Another error occurred which shows that cannot import name default.

like image 620
Alex Avatar asked Aug 05 '16 09:08

Alex


3 Answers

Use of patterns is deprecated since django 1.8. See docs. You can use plain lists now.

like image 120
ger.s.brett Avatar answered Nov 03 '22 17:11

ger.s.brett


The use of patterns is deprecated in Django1.10. Therefore do not import 'patterns' and your url pattern should be as follows:

from django.conf.urls import include, url

urlpatterns=[
    url(r'^admin/', include(admin.site.urls)),
    url(........),
]
like image 27
user2947136 Avatar answered Nov 03 '22 16:11

user2947136


I ran into this error when trying to install Django-Guardian. Instead of downgrading Django, you can install the latest version of Django-Guardian. Try,

pip install 'django-guardian>=1.4.6'

This resolved the issue for me.

like image 4
Davinder Avatar answered Nov 03 '22 16:11

Davinder