HI All,
I'm new in Django and in Web-Development. Therefore I'm a little confused 
now.
I have taken over a Django project and first I want to upgrade it to the 
actual version.
Now I was doing the migration to Django 1.9.12 and struggling with the 
following problem:


Using ModelFormMixin (base class of MFormsView) without the 'fields' attribute 
is prohibited.
>
>
My views.py is having a class which is defined like:
class MFormsView(LoginRequiredMixin, MFView):
    template_name = 'temps/cnfg_form.html'
    form_classes = {
        'abc': abcForm,
        'md': mdForm,
    }
...
...


There is a separate module mfview.py which contains a class MFView:
class MFView(ProcessFormView):
    """
    A mixin that processes multiple forms on POST. Every form must be
    valid.
    """
    def get(self, request, *args, **kwargs):
        form_classes = self.get_form_classes()
        forms = self.get_forms(form_classes)
        return self.render_to_response(self.get_context_data(forms=forms))
...
...

The forms passed to the get_context_data contains the 'abc': abcForm and 
the 'md': mdForm.
Form both ModelForms abcForm and mdForm the fields are defined.

The template uses the forms and fields like:
<div class="col-md-5">{{ forms.abc.days }}</div>
or (in the same template)
<div class="col-md-13 checkbox col-sm-pad">{{ forms.md.started }}</div>

This worked well like that until Django 1.8, but now with Django 1.9 the 
following error occurs:

> Using ModelFormMixin (base class of MFormsView) without the 'fields' 
> attribute is prohibited.
>
>
Now my question:
1.) Why do I get this message, as the fields are defined in both ModelForms?
2.) What is the best way to include 2 different forms into the same 
template? Do you have an example?

Thanks
schaf

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ced05b74-2213-4de1-9610-1ca1767f2f7c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to