Giter Site home page Giter Site logo

valian / django-multiple-forms Goto Github PK

View Code? Open in Web Editor NEW
8.0 8.0 7.0 8 KB

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

Python 95.53% HTML 4.47%

django-multiple-forms's People

Contributors

valian avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

django-multiple-forms's Issues

'super' object has no attribute 'form_valid'

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):

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.