On Monday 23 January 2017 06:41:53 schaf...@gmail.com wrote:

> This worked well like that until Django 1.8, but now with Django 1.9

This stopped working in Django 1.8[1] :
"Class-based views that use ModelFormMixin will raise an ImproperlyConfigured 
exception when both the fields and form_class attributes are specified. 
Previously, 
fields was silently ignored."

And burried in the docs[2], a different case for the same thing:
In older versions, omitting both fields and exclude resulted in a form with all 
the 
model’s fields. Doing this now raises an ImproperlyConfigured exception.

For someone who didn't follow the discussion on the topic, it sure is hard to 
find in 
release notes.

> 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?

The model form is missing a 'fields' attribute. Example:
*class ComponentStockAllocationAssign(*StockMixin, generic.CreateView*):    
*model 
*= *models.ComponentLocationStock    *_fields _**_= ['component', 'location', 
'stock']_*
success_url *= *reverse_lazy*("component_allocation_list")

*

> 2.) What is the best way to include 2 different forms
> into the same template? Do you have an example?

That's a much bigger question than it seems. What's the relation between the 
forms?
If they're unrelated, implement get_context_data() to assign them, and 
form_valid() to 
process them.
Also, bookmark this: https://ccbv.co.uk/
-- 
Melvyn Sopacua

--------
[1] https://docs.djangoproject.com/en/1.9/releases/1.8/#miscellaneous
[2] 
https://docs.djangoproject.com/en/1.9/topics/forms/modelforms/#selecting-the-fields-to-use

-- 
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/2373219.g3W5xVLTHe%40devstation.
For more options, visit https://groups.google.com/d/optout.

Reply via email to