Page not found (404)

My is like below.

path('register/', PatientRegisterView.as_view(), name='register'),

My 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 =
        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">

But I am getting Page not found (404) error.

The Problem is the action attribute

It should be

<form method="POST" action=".">
        {% csrf_token %}
        {{ form.as_p }}
        <input type="submit" value="Register">

<form>: The Form element - HTML: HyperText Markup Language | MDN (

1 Like