Ok, I resolved just adding a 'codice' key with the right value to the
f.clean_data dict before saving...
Is there a better way or can I stay with this?


On Jul 20, 4:35 pm, ilDave <[EMAIL PROTECTED]> wrote:
> Hello!
> I'm using form_for_model to create a form for a particulary complex
> model.
> I don't want to show a particular field of the model in the form, so I
> did this:
>
> PreventivoForm =  form_for_model(Preventivo)  #Preventivo is the name
> of the model
> del PreventivoForm.base_fields['codice'] # codice is the field I don't
> want to show, because it's value must
> be
>                                                            #
> calculated from other data
>
> and the form is nicely displayed like I want.
>
> But when I try to save the data in the form in a new model, I get an
> exception, because the 'codice' field is a required field in the
> model:
>
> f = PreventivoForm(request.POST)
> if f.is_valid():
>        p = f.save()
>
> Is there a way to add the field I need before saving or have I to
> handle the saving of the object manually?


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