Re: django forms - overriding constructor for changing field type depending by input

2012-05-21 Thread bruno desthuilliers
On May 20, 5:28 pm, luke lukes wrote: > thanks Paul and DR, your solution worked. anyway now i have a problem with > the validation of that form (her's the view): (snip) Sorry, your code's indentation get messed up so it's hard to tell where the problem ise exactly.

Re: django forms - overriding constructor for changing field type depending by input

2012-05-20 Thread luke lukes
thanks Paul and DR, your solution worked. anyway now i have a problem with the validation of that form (her's the view): *def anagrafica_save(request):* *if request.method == 'POST':* *form = AnagraficaForm(request.POST)* *if'idsogg' in request.POST:* *soggetto =

Re: django forms - overriding constructor for changing field type depending by input

2012-05-20 Thread Paul Prior
I think you need self.fields[field_name] = your new field. Paul On May 20, 2012, at 7:49 AM, luke lukes wrote: > Hi. already tried this way --> fields are instantiated > () but are not > rendered in the template... > > Il giorno domenica 20 maggio 2012 03:25:36 UTC+2,

Re: django forms - overriding constructor for changing field type depending by input

2012-05-20 Thread Daniel Roseman
On Sunday, 20 May 2012 12:49:28 UTC+1, luke lukes wrote: > > Hi. already tried this way --> fields are instantiated > () but are not > rendered in the template... > >> >> You should be assigning your new fields to `self.fields['fieldname']`, not `self.fieldname`. -- DR. -- You received this

Re: django forms - overriding constructor for changing field type depending by input

2012-05-20 Thread luke lukes
Il giorno domenica 20 maggio 2012 13:49:28 UTC+2, luke lukes ha scritto: > > Hi. already tried this way --> fields are instantiated > () but are not > rendered in the template... > > Il giorno domenica 20 maggio 2012 03:25:36 UTC+2, somecallitblues ha > scritto: >> >> Hey Luke, >> >> I don't

Re: django forms - overriding constructor for changing field type depending by input

2012-05-20 Thread luke lukes
Hi. already tried this way --> fields are instantiated () but are not rendered in the template... Il giorno domenica 20 maggio 2012 03:25:36 UTC+2, somecallitblues ha scritto: > > Hey Luke, > > I don't think you need to return anything, especially not a super class. > > Try this

Re: django forms - overriding constructor for changing field type depending by input

2012-05-19 Thread Mario Gudelj
Hey Luke, I don't think you need to return anything, especially not a super class. Try this http://dpaste.com/hold/750356/ Cheers, -m On 20 May 2012 10:06, luke lukes wrote: > hi everyone. i need to overrid the constructor of a form: if i have some > value in input,

django forms - overriding constructor for changing field type depending by input

2012-05-19 Thread luke lukes
hi everyone. i need to overrid the constructor of a form: if i have some value in input, some fields has to be ChoiceField, otherwise they have to be CharField. here's the code: http://dpaste.com/750343/ but this way doesn't work. even if i declare fields before constructor as CharField and