My urls.py
is like below.
path('register/', PatientRegisterView.as_view(), name='register'),
My views.py
code is like below
class PatientRegisterView(FormView):
template_name = 'register.html'
# fields = '__all__'
form_class = UserCreationForm
redirect_authenticated_user = True
success_url = reverse_lazy('dashboard')
def form_valid( self, form ):
user = form.save()
if user is not None:
login( self.request, user )
return super( PatientRegisterView, self ).form_valid( form )
def get( self, *args, **kwargs ):
if self.request.user.is_authenticated:
return redirect('register')
return super(PatientRegisterView, self).get(*args, **kwargs)
My reigster.html
code is like below.
<form action="POST">
{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Register">
</form>
But I am getting Page not found (404)
error.