How can I get the object value of a combobox in django view? -
i creating app in django , have form field 'person' foreignkey field. so, when run application appears form correctly showing me combobox lets me select 'person' object want. problem when try catch information in view.
i send data post method, so, when try value of selected 'person' object in view next:
selected_person = request.post['person']
(person field name)
i surprised when tested value of variable 'selected_person' number (concretely, number of selected index of element in combobox).
my question is: how can object value of selected element in combobox?
than much!
no, primary key of person object in database. can via person.objects.get(pk=selected_person)
.
but should using django form, give person object via form.cleaned_data['person']
.
also note, clarity, select field, or drop-down, not combobox; combobox desktop widget has both drop-down , edit field.
Comments
Post a Comment