0

I want to get the attributes of an ModelForm. Actually I create an ModelForm(request.POST) object and then I use a for-loop to get fields of the ModelForm. But I only geht the referenc of this objects not the content. What can I do?

  forms = FormSet(request.POST, prefix='probe')
  for form in forms:
       form.fields['some_id']

With this code I get some stuff like this:

  <django.forms.models.ModelChoiceField object at 0x034705B0>

Do somebody now how I get the content of this object?

4

1 回答 1

1
if form.is_valid(): #validate the form
    cleaned_data = form.cleaned_data
    print cleaned_data['some_id'] #print out the choice
于 2013-06-05T20:37:02.573 回答