Thursday, October 27, 2011

Re: Field.Choices in Template

On Wed, Oct 26, 2011 at 7:22 PM, Kurtis Mullins
<kurtis.mullins@gmail.com> wrote:
> Hey Guys,
> I hate to bother you again. But -- is there a way to get the currently
> selected data from this set? For example, a user hits the page and all
> choices are displayed fine. But, they pick some choices. They haven't
> finished editing the form or maybe they made a mistake, anyways they land in
> the form_invalid land. I'd like to be able to use this same technique to
> make sure I properly display what the user has selected thus-far.
> Thanks!
>

Are you hand generating the widgets? That seems crazy, you lose all of
the benefits of django doing it for you.

To access the value of a BoundField, call the value() method on it. In
a template:

{% for field in form %}{{ field.value }}{% endfor %}


Cheers

Tom

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment