I have a view that uses one of the class-based generic views (derived from django.views.generic.DetailView) with a custom form:
from django.views.generic import DetailView class MyDetailView(DetailView): model=MyModel def get_object(self): object = MyModel.objects.get(uuid=self.kwargs['uuid']) def get_context_data(self, **kwargs): form = MyForm context = super(MyDetailView, self).get_context_data(**kwargs) context['form'] = form return context
I would like POST to submit the form sent to the same URL as GET. Is it possible to change this view code so that it can also respond to POST? If so, how? Do I need to inherit from another mixin class? And what is the name of the method you need to add to process the form data?
Or is it just a bad idea to respond to POST at the same URL for this script?
(Note: the form does not change the displayed MyModel, but is used to create a model object of a different type, so UpdateView is not very suitable).
source share