1👍
The get_context_data
method is used to fetch the data which is used to render the template. It shouldn’t really be creating users or carrying out other actions.
You can override dispatch()
, but a more common approach would be to override get()
or post()
depending on whichever request type you are dealing with. The base implementation of dispatch()
calls the appropriate method depending on the request type (e.g. get()
or post()
)
If you are validating POST variables, then you should consider using Django forms, and subclassing the FormView
.
Classy Class-Based Views is a good resource for exploring the methods or class based views.
Finally, you don’t have to use a class based view, there’s nothing wrong with using a function based view if you’re happier structuring your code that way.