What is difference between Django FormView and CreateView?
Only diffrence I see, FormView require ModelForm but CreateView doesn't.
Otherwise both does same thing creating an object.
From Django-docs:
A view that displays a form. On error, redisplays the form with validation errors; on success, redirects to a new URL.
It can be used for various purposes and is not restricted to creating objects. A nice example would be using it as a contact form and sending emails without creating records in database.
A view that displays a form for creating an object, redisplaying the form with validation errors (if there are any) and saving the object.
The sole purpose of this generic view is to create objects. But it is not limited to creating objects. You can send emails from this view too (just like FormView)
If your FormView
creates model objects, it is best to use CreateView
and not creating a modelform, that's what generic views are for, reducing repetition.
fields
attribute.