Which Class Based View is perfect for User Registration ?
from django.views.generic.edit import FormView
or
from django.views import View
Is there any other Class Based View for User Registration ?
Which Class Based View is perfect for User Registration ?
from django.views.generic.edit import FormView
or
from django.views import View
Is there any other Class Based View for User Registration ?
I don’t know about “perfect”, but of the Django-provided CBVs, it seems to me that CreateView would be the closest fit for a User Registration page. (You’re creating a User
object from the form.)
Thanks @KenWhitesell . Actually I used FormView
view before. Now I am trying to use View
. I am found that View
is not so helpful like FormView
. That’s why I asked that.
Which one do you use for User Registration ?
For my personal projects, it’s CreateView.
FormView
just displays a specified form (as per the form_class
attribute) and redirects to a specified page when the submitted form validates OK (assuming the submit
method was POST). View
is extremely basic. Neither Formview
nor View
deals with a model object (but you could always override the form_valid()
method in FormView
to alter the model object). View
leaves you to do all the extra work which may be okay when you want full control.
Otherwise, CreateView
gives you everything that FormView
does but with the added advantage of altering/saving the associated model object.
Check out this resource for more understanding of Class-Based Views.