Python / Django Forms - Display Form Element Content Instead of Html Element -
i looping through forms , want display of values of form elements. have read .data should take care of me. however, returns "none" , form indeed have field , correct stored value...
{% document in documents: %} {{ document.title.data }} <!-- note: returns "none" --> {{ document.title }} <!-- element correct initial value --> any ideas?
merci beaucoup!!!
update:
to access initial value directly
forms.charfield(initial=x)
use{{ document.title.field.initial }}.accessing initial value passed form constructor (
form = myform(initial={...})) doesn't possible via template.boundfielddata = self.form.initial.get(self.name, self.field.initial)when rendering widget @ forminitialdict, falls form field's initial value.for bound form you've passed in data, such
form = myform(request.post), data available in{{ document.title.data }}
in trunk, boundfield.value returns either initial or data! cool stuff. http://code.djangoproject.com/browser/django/trunk/django/forms/forms.py#l438
Comments
Post a Comment