I have to remove the field from the object class and not from the
class instance...

Thanks!

On Jul 9, 12:52 pm, Nathan Ostgard <[EMAIL PROTECTED]> wrote:
> Do this instead:
>
> PreventivoForm = form_for_model(Preventivo)
> del PreventivoForm.base_fields['codice']
> f = PreventivoForm()
> f2 = PreventivoForm(auto_id='id_%s2')
>
> ----
> Nathan Ostgard
>
> On Jul 9, 2:33 am, ilDave <[EMAIL PROTECTED]> wrote:
>
> > Hi!
> > I have to show two identical forms in a page, so I used form_for_model
> > and I created two form objects.
> > I don't need to show a particular field, so i tried to remove it this
> > way:
>
> > def showtwoforms(request):
> >     PreventivoForm =  form_for_model(Preventivo) #'Preventivo' is the
> > model
> >     f = PreventivoForm()
> >     if f.base_fields.has_key('codice'): #codice is the field I want to
> > get rid of
> >         del f.base_fields['codice']
> >     f2 = PreventivoForm(auto_id='id_%s2')
> >     if f2.base_fields.has_key('codice'):
> >         del f2.base_fields['codice']
> >     t = loader.get_template('preventivo.html')
> >     c = Context({
> >               'form' : f,
> >               'form2' : f2,
> >               })
> >     return HttpResponse(t.render(c))
>
> > But when I show the page, only the second form (f2) has not the
> > 'codice' field, the first form still has it.
>
> > What am I missing?
>
> > Thanks!


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