Re: accessing to a field value in the template

2008-12-22 Thread Malcolm Tredinnick

On Mon, 2008-12-22 at 17:20 -0600, GaRaGeD Style wrote:
> > 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.
> 
> 
> So, ther is no way to access (1) data ?? I'm doing an app with
> django/dojo, and I need to display fields manually, I could make them
> programatically, but that would be "a lot more work", the problem I
> have now is that when the user submits data with errors, I cannot
> redisplay the fields with values, so there is no way to degrade
> gracefully (I'm not that interested on that actually, but could be
> nice).

Have a look in django/forms/forms.py at the class BoundField. That is
the object that is a "field" in the template. You can see there how the
data value is retrieved by the code.

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



Re: accessing to a field value in the template

2008-12-22 Thread GaRaGeD Style

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


So, ther is no way to access (1) data ?? I'm doing an app with
django/dojo, and I need to display fields manually, I could make them
programatically, but that would be "a lot more work", the problem I
have now is that when the user submits data with errors, I cannot
redisplay the fields with values, so there is no way to degrade
gracefully (I'm not that interested on that actually, but could be
nice).

Max

-- 
$ echo "scale=100; 4*a(1)" | bc -l

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



Re: accessing to a field value in the template

2008-12-21 Thread Malcolm Tredinnick

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



accessing to a field value in the template

2008-12-21 Thread irunsoft

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 = 
it is possible to get the value only through a template ?  Something
like field.value ? or field.data ? or field.initial ??

I have tried all of them but cannot access to the value.  If you have
any hint it will be appreciate.

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