Skip to content

Instantly share code, notes, and snippets.

@jamesbrobb
jamesbrobb / multiform.py
Last active July 4, 2023 18:53 — forked from michelts/gist:1029336
django multiform mixin and view that allows the submission of a) All forms b) Grouped forms c) An individual form
class MultiFormMixin(ContextMixin):
form_classes = {}
prefixes = {}
success_urls = {}
grouped_forms = {}
initial = {}
prefix = None
success_url = None
from django.views.generic.base import View, TemplateResponseMixin
from django.views.generic.edit import FormMixin, ProcessFormView
class MultipleFormsMixin(FormMixin):
"""
A mixin that provides a way to show and handle several forms in a
request.
"""
form_classes = {} # set the form classes as a mapping