[Django] #27016: django-admin.py startproject creates urls.py that raises ImportError

2 views
Skip to first unread message

Django

unread,
Aug 4, 2016, 6:34:24 AM8/4/16
to django-...@googlegroups.com
#27016: django-admin.py startproject creates urls.py that raises ImportError
-----------------------------+---------------------------------------------
Reporter: stemaan | Owner: nobody
Type: Bug | Status: new
Component: Core (URLs) | Version: 1.10
Severity: Normal | Keywords: startproject, ImportError, urls
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------+---------------------------------------------
This is the default urls.py file created by above command:

{{{
from django.conf.urls import patterns, include, url

from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
# Examples:
# url(r'^$', 'plab_django_admin.views.home', name='home'),
# url(r'^blog/', include('blog.urls')),

url(r'^admin/', include(admin.site.urls)),
)
}}}

having such a setup, after running a runserver command leads to:

{{{
ImportError: cannot import name patterns
}}}

According to [https://docs.djangoproject.com/en/1.10/releases/1.10
/#features-removed-in-1-10 Feature removed in 1.10]
{{{
django.conf.urls.patterns() is removed.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27016>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Aug 4, 2016, 6:40:31 AM8/4/16
to django-...@googlegroups.com
#27016: django-admin.py startproject creates urls.py that raises ImportError
-------------------------------------+-------------------------------------
Reporter: stemaan | Owner: nobody
Type: Bug | Status: closed

Component: Core (URLs) | Version: 1.10
Severity: Normal | Resolution: invalid
Keywords: startproject, | Triage Stage:
ImportError, urls | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by bmispelon):

* status: new => closed
* needs_better_patch: => 0
* resolution: => invalid
* needs_tests: => 0
* needs_docs: => 0


Comment:

Hi,

I think there's an issue with your setup where `django-admin.py` uses an
older version of Django (1.7 by the looks of it) but your project actually
uses a more recent (1.10) Django version.


When using Django 1.10, `django-admin.py startproject` will use correct
imports.

Can yo ucheck what `django-admin.py --version` returns? I'll mark this
ticket as `invalid` for now but please reopen it if it turns out my
analysis is incorrect.


Thanks.

--
Ticket URL: <https://code.djangoproject.com/ticket/27016#comment:1>

Reply all
Reply to author
Forward
0 new messages