I am working on a project and I am getting this following error:
traceback:
TypeError at /account/reset-password
__init__() takes 1 positional argument but 2 were given
imports:
from django.conf.urls import url
from . import views
from django.contrib.auth import views as auth_views
from django.contrib.auth.views import PasswordResetView, PasswordResetDoneView
url:
url(r'^reset-password$', PasswordResetView, name='reset_password'),
I am new to django, so welcomed help . ty
The PasswordResetView
[Django-doc] is a class-based view, you should specify the URL as:
url(r'^reset-password$', PasswordResetView.as_view(), name='reset_password'),
You do not want to create a new PasswordResetView
each time you pass to the view, you want to create a HTTP response. The reason why you get the error is because now you will create a PasswordResetView
(so you will call the __init__(..)
method of the PasswordResetView
class. There is a mismatch between the parameters used by the view, and the constructor of the object, hence the error. Even if there was no mismatch, there would - luckily enough - still be an error, since the result would be a PasswordResetView
object, which is not a subclass of a HttpResponse
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With