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?