Malcom,

I looked at the ModelForm documentation and to be honest with you i don't 
understand how am i suppose to change or add a required value that i excluded. 
I should underscore that i am fairly new to django so please bare with me.
I tried coping request.POST into a dictionary variable and adding the required 
value and then create my form instance like this:

if request.method == 'POST':
        data = copy(request.POST)
        data['required_field'] = value
        form = forms.Model2Form(data)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect("")

but i get the same error. As for your second suggestion i am not quite sure 
what should i do.
Thanks,
 
Jorge Hugo Murillo

When a ModelForm is saved it doesn't take the data from attributes on
the form like you're guessing it does. It looks in cleaned_data.

So you could pass in your compulsory values when initialising the form
instance (make a dictionary that combines request.POST and the required
values and pass that to the constructor instead of request.POST).

Or you could write a save() method on your form that passes commit=False
to the ModelForm.save() method and then update the object instance and
save it in your own method. That's the most logical approach -- you want
different save() behaviour, so you override the default save() method.
It's all documented in the modelforms documentation.

Regards,
Malcolm

> 
-- 
Monday is an awful way to spend 1/7th of your life. 
http://www.pointy-stick.com/blog/









      
____________________________________________________________________________________
You rock. That's why Blockbuster's offering you one month of Blockbuster Total 
Access, No Cost.  
http://tc.deals.yahoo.com/tc/blockbuster/text5.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to