Re: Issue when rendering manually a form's HiddenInput

24 views
Skip to first unread message

Tom Evans

unread,
Aug 7, 2015, 7:07:49 AM8/7/15
to django...@googlegroups.com
On Thu, Aug 6, 2015 at 6:55 PM, <durir...@gmail.com> wrote:
> So, I'm trying to use inputs with the hidden attr. I have my form class
> (IndexForm) that has this:
> field = HiddenInput()
> Then, I pass the instance of IndexForm (index_form) to the template, and
> manually render the field (index_form.field). It is alright, but then, in
> the HTML, the render of the field is this...
> <django.forms.widgets.HiddenInput object at 0xb6076dcc>
> Why I'm seeing the str representation of the object, and not an HTML hidden
> input?

Forms are collections of Field instances, but HiddenInput is a Widget.
You should be setting the widget attribute of one of the fields to be
a HiddenInput, not assigning a HiddenInput as a member of the form.

Cheers

Tom

durir...@gmail.com

unread,
Aug 7, 2015, 10:12:03 AM8/7/15
to Django users
Yeah, I deleted the post cause I thinked the same yesterday. Sorry for the inconvenience.
Reply all
Reply to author
Forward
0 new messages