valian / django-multiple-forms Goto Github PK
View Code? Open in Web Editor NEWMixin and generic view for django CBV to display multiple forms on the same page.
Home Page: https://rock-it.pl/multiple-forms-on-one-page-in-django
Mixin and generic view for django CBV to display multiple forms on the same page.
Home Page: https://rock-it.pl/multiple-forms-on-one-page-in-django
Hi, just found your gist, and I think it can help me out. the thing is that when using according to your blog but I'm getting:
'super' object has no attribute 'form_valid'
I've commented the method: 'def get_forms_classes(self)" as I don't need to make restrictions based on user status.
You may be wondering, "there is only one form there: "ReferenciaForm". My Issue is that I need to make a form for every "Referencia" (spanish for reference) object inside "nucleo_referencia" table. I would appreciate if you could point me to the correct query to this to work with your gist. Thanks.
views.py
class MultipleFormsDemoView(MultipleFormsView):
template_name = 'app_administrador/validar-referencias-nana.html'
success_url = '/'
# here we specify all forms that should be displayed
forms_classes = [
ReferenciaForm
]
# def get_forms_classes(self):
# # we hide staff_only forms from not-staff users
# # our goal no. 3 about dynamic amount list of forms
# forms_classes = super(MultipleFormsDemoView, self).get_forms_classes()
# user = self.request.user
# if not user.is_authenticated() or not user.is_staff:
# return list(filter(lambda form: not getattr(form, 'staff_only', False), forms_classes))
# return forms_classes
def form_valid(self, form):
print("yay it's valid!")
return super(MultipleFormsDemoView).form_valid(form)
Also, I'm noticing that the last line in your gist is:
class MultipleFormsView(TemplateResponseMixin, MultipleFormsMixin, ProcessFormView):
pass
As it has pass
, I'm wondering if we should write something there... and this is the class I'm using in my view file:
# View with multiple forms, inheriting our Generic MultipleFormsView
class MultipleFormsDemoView(MultipleFormsView):
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.