On Thursday, 25 August 2011 06:10:38 UTC+1, raj wrote:
>
> I'm trying to set a default form value in the template, and not in the 
> forms.py file (because I'm trying to make the default value dynamic 
> depending on something that javascript will return). 
> So To test it, I have the following line in my template: 
>
> {{ form.first_name|default:"Enter Your first name" }} 
>
> The issue is that it doesn't work, And I can't figure out why. Am I 
> doing something illegal? 
> Help Please. Thank you.

No, that doesn't work at all, and never will. The "default" filter is for 
providing a value in case a particular context variable is empty, not for 
setting a form field's default value.

Your reasoning doesn't seem to make sense, in any case. Templates are 
rendered server-side, so Javascript can have no effect on what is rendered. 
Do this in the view.
--
DR.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/-f3lHGNQynIJ.
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