How would you deal with the case of having two separate forms and two models but sharing the same CreateView?
For example if you have two models that inherit one abstract model, and in the CreateView we include both forms in context
. Whichever form the user submits, should create an instance of its associated model.
class EventCreateView(generic_view.CreateView):
template_name = 'event/create.html'
form_class = OneToOneEventForm
second_form_class = GroupEventForm
def get_context_data(self, **kwargs):
context = super(EventCreateView, self).get_context_data(**kwargs)
if 'form' not in context:
context['form'] = self.form_class()
if 'form2' not in context:
context['form2'] = self.second_form_class()
return context
## how would we deal with post() and form_valid() and object creation?