Django class based views for using more than one Form or ModelForm in a single view.
$ pip install django-multi-form-viewfrom multi_form_view import MultiModelFormView class RecordFormView(MultiModelFormView): form_classes = { 'photo_form' : PhotoForm, 'record_form' : RecordForm } record_id=None template_name = 'records_form.html' def get_objects(self): self.record_id = self.kwargs.get('record_id', None) try: record = Record.objects.get(id=self.record_id) except Record.DoesNotExist: record = None return { 'record_form': record, 'photo_form': record.photo if record else None } def get_success_url(self): return reverse('records') def forms_valid(self, forms): photo = forms['photo_form'].save() record = forms['record_form'].save(commit=False) record.photo = photo record.save() return HttpResponseRedirect(self.get_success_url())$ cd demo $ pip install -r requirements.txt $ python manage.py migrate $ python manage.py runserver$ python demo/manage.py behave