Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Patterns" and multiple discrepancies. #49

Closed
jorgeOmurillo opened this issue Jun 27, 2016 · 2 comments
Closed

"Patterns" and multiple discrepancies. #49

jorgeOmurillo opened this issue Jun 27, 2016 · 2 comments

Comments

@jorgeOmurillo
Copy link

jorgeOmurillo commented Jun 27, 2016

In the mysite/urls.py, the code is completely different than how the Django Girls tutorial ends:

It looks like:

from django.conf.urls import include, url
from django.contrib import admin

urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'', include('blog.urls')),
]

The "Homework: secure your website" shows:

from django.conf.urls import include, url
import django.contrib.auth.views

from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
url(r'^admin/', include(admin.site.urls)),
url(r'^accounts/login/$', django.contrib.auth.views.login, name='login'),
url(r'^accounts/logout/$', django.contrib.auth.views.logout, name='logout', kwargs={'next_page': '/'}),
url(r'', include('blog.urls')),
)

When importing "patterns", Python throws an error that it is deprecated since v1.10.

@rege-django
Copy link

from django.conf.urls import include, url
from django.contrib.auth import views

from django.contrib import admin
admin.autodiscover()

urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^accounts/login/$', views.login, name='login'),
url(r'^accounts/logout/$', views.logout, name='logout', kwargs={'next_page': '/'}),
url(r'',include('blog.urls')),
]

this works!

@helenst
Copy link
Contributor

helenst commented Oct 1, 2016

Thank you for pointing this out. The main tutorial was updated to Django 1.9 (which gives you this style of urls by default) but the extensions haven't been so it's out of sync now.

@rege-django we'd welcome a pull request if you would like to submit one (note that the admin.autodiscover() line can be taken out as Django no longer uses that) Thanks! 🐬

helenst added a commit that referenced this issue Nov 26, 2016
* Use new-style urlpatterns
* remove admin.autodiscover

Fixes #49 and #9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants