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 = Anagrafica.objects.get(pk=request.POST["idsogg"])* * else:* * soggetto = Anagrafica()* * * * if form.is_valid():* * .... #set model fields and save* * ...* * else:* * print('errors',form.errors)* * sub = "Scheda soggetto anagrafica"* * dict = {'sub':sub, 'subsogg':soggetto, 'form':form}* * return render_to_response('anagrafica_form.html', dict, context_instance=RequestContext(request))* The form is always not valid, also the form.errors print show an empty dict. The form is returned back and instead of renderized ChoiceFields as select, i got these messages printed in html: <django.forms.fields.ChoiceField object at 0x7ff264215110>...any help? Il giorno domenica 20 maggio 2012 14:21:39 UTC+2, Paul Prior ha scritto: > > I think you need self.fields[field_name] = your new field. > Paul > > > > On May 20, 2012, at 7:49 AM, luke lukes <lordluk...@gmail.com> wrote: > > Hi. already tried this way --> fields are instantiated > (<django.forms.fields.ChoiceField object at 0x7f6204206f10>) 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 http://dpaste.com/hold/750356/ >> >> Cheers, >> >> -m >> >> >> >> On 20 May 2012 10:06, luke lukes <lordluk...@gmail.com> wrote: >> >>> 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 then I ovverride them in __init__, they will not be >>> renderized in template (I got this message: >>> <django.forms.fields.ChoiceField object at 0x7ff0c0173ad0>).I don't >>> understand where's the mistake (also because i have poor python skills...) >>> >>> any help? >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Django users" group. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msg/django-users/-/lIzEfD5QeZMJ. >>> To post to this group, send email to django-users@googlegroups.com. >>> To unsubscribe from this group, send email to >>> django-users+unsubscr...@googlegroups.com. >>> For more options, visit this group at >>> http://groups.google.com/group/django-users?hl=en. >>> >> >> -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/django-users/-/a67HgD8GqvgJ. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/TMcE4PDrXMkJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.