On Sun, 2008-12-21 at 19:57 -0800, iruns...@gmail.com wrote:
> Hi,
> 
> I am new in Django and I am wondering if it is possible to access to a
> form field value in through a template.
> 
> I know that I can access to the field by {{field}} and also can access
> to the field.label, errors, label_tag, but I would like to access to
> the intial value of a field.
> 
> Suppose I have the field = <input type="text" id="id_myfield"
> name="myfield" value="1000">
> it is possible to get the value only through a template ?  Something
> like field.value ? or field.data ? or field.initial ??

In the current code, that particular value isn't easily available, no,
and that is probably an omission we should fix.

That particular value comes from one of three sources. In order of
highest priority to lowest, they are:

        (1) Data submitted to the form (for redisplaying submitted data
        for errors).
        (2) Initial data provided to the form class
        (3) Initial data provided to the field class (when it was
        created as part of the form).
        
The code does a semi-complex dance to pull out the right value and it's
not something you can really emulate at the template level. That's
something worth adding for Django 1.1.

Regards,
Malcolm



--~--~---------~--~----~------------~-------~--~----~
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