Django 2.1 changes?


#1

I appreciate the books are written for a specific point in time/version of Django but I’m wondering if there will be any updates for Django 2.1?

I’ve tried the upgrade and am hitting some issues around the “Adding a Registration Page” section of the book. Specifically around the deprecation of django.contrib.auth.views: password_reset, password_reset_done… etc.

Cheers,
Nick


#2

Right now I don’t have the time to make all the updates for Django 2,1 officially – I usually wait a bit longer in between updates. Officially, Hello Web App should be used with Django 2.0 only at the moment.

Looks like those views were moved to django.contrib.auth (rather than django.contrib.auth.views). Have you tried importing from there instead?

(This is where I got that info, if that helps: https://docs.djangoproject.com/en/2.1/topics/auth/default/)


#3

I get import errors, as far as I can tell those views were removed or renamed.

per release notes here: https://docs.djangoproject.com/en/2.1/releases/2.1/

Features removed in 2.1¶

These features have reached the end of their deprecation cycle and are removed in Django 2.1. See >Features deprecated in 1.11 for details, including how to remove usage of these features.

contrib.auth.views.login(), logout(), password_change(), password_change_done(), password_reset(), >password_reset_done(), password_reset_confirm(), and password_reset_complete() are removed.


#4

Resetting password (new views model/syntax for Django 2.1) problem solved (location 1333 of e-book in Kindle Reader):

importing the new views must be as follows:

from django.contrib.auth.views import (

(old) password_reset -> (new) PasswordResetView
password_reset_done -> PasswordResetDoneView
password_reset_confirm -> PasswordConfirmView
password_reset_complete -> PasswordResetCompleteView

the urlpatterns also change a bit, new syntax is as follows (just giving the one example as you’ll get the gist):

path(‘accounts/password/reset/’, PasswordResetView.as_view(template_name=‘registration/password_reset_form.html’), name=‘password_reset’),


#5

Yay, thank you so much for this info, it’s super helpful! 👍


#6

PasswordConfirmView is not working!Has any one been able to solve this?
I’m seeing an error like this: path(‘reset-password/confirm’, PasswordConfirmView.as_view(),
NameError: name ‘PasswordConfirmView’ is not defined


#7

Sounds like you’re missing the import statement? What does your urls.py look like? You can use pastebin to share the code. :)


ImportError: cannot import name 'password_reset'
#8

Hate to necro, but some might find useful.

from django.contrib.auth.views import(
    PasswordResetView,
    PasswordResetDoneView,
    PasswordResetConfirmView,
    PasswordResetCompleteView
)


path('accounts/password/reset/',PasswordResetView.as_view(),name="password_reset"),
path('accounts/password/reset/done/',PasswordResetDoneView.as_view(),name="password_reset_done"),
path('accounts/password/reset/<uidb64>/<token>/',PasswordResetConfirmView.as_view(),name="password_reset_confirm"),
path('accounts/password/done',PasswordResetCompleteView.as_view(),name="password_reset_complete"),
path('accounts/', include('registration.backends.simple.urls')),
path('admin/', admin.site.urls),

#9

Thank you!