On Fri, 2009-03-13 at 21:08 -0700, ihome wrote:
> Hi,
> 
> I am using the latest django development version and have some problem
> with the render_to_response to render a template. Here is a short
> snippet:
> 
>     return render_to_response('index.html', {
>         'form': form,
>         'ops' : ops,
>       })
> 
> form comes from a newly defined data form inherited from forms.Form.
> For one line in my template index.html:
> 
> <input name="v" type="text" value="{{ form.v }}" />
> 
> The rendered html page looks like:
> 
> <input name="v" type="text" value="<input type="text" name="p"
> value="100" id="id_p" />" />
> 
> Not sure why the render_to_response want to generate a whole <input
> type="text" name="p" value="100" id="id_p" /> for my {{  form.v }}

Because form.v is a BoundField instance that knows how to render itself.
The idea is that you only include {{ form.v }} in the template and it
renders nicely in 90% of cases.

> 
> Do I miss anything here? 
> I do not want this pre-defined behaviour.

Then don't do that.

You'll need to extract individual elements from inside the BoundField
instance and render those individually. Except, you can't do that solely
from templates at the moment, because getting the correct value for the
field isn't possible. You would need to write a custom template filter
to extract the necessary information.

That will be changed in Django 1.1 -- track ticket #10427 if you're
interested in following progress there.

Regards,
Malcolm


>  Is
> there a way to turn it off. For ops dict type, everything works as
> expected.
> 
> Thanks.
> 
> 
> > 
> 


--~--~---------~--~----~------------~-------~--~----~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to