> How does Django enable the ability to pass variables to a Form or a
> Template whose purpose is only to be displayed?
Given that the input has been validated correctly and does not throw
an error you can access the value with
form.cleaned_data.username
If you want to pass a variable to a template, try
# view.py or whereever your code lives
return render_to_response('template.html' { 'templatevar': 'the
content of the var' })
# template.html
{{ templatevar }}
On 16 Mrz., 18:15, NoviceSortOf <[email protected]> wrote:
> I just want to say Hello Mary in my HTML code pulling Mary's username
> from the request.data.
>
> I've dug through the documentation and through this group, but am
> still baffled by
> what seems the inability of Django to allow someone to display a value
> in some format
> other than an input variable of a form.
>
> For instance if the users name is "Mary", and Mary has logged in...
>
> in view.py then
> ...
> thisusername = request.user.username
> data = {'thisusername':username,}
> form = form_class(data)
> ....
>
> now in the hello.html how do you say Hello Mary?
>
> when I try {{ form.thisusername }} - i get an input field
>
> when i try coding html like
>
> <input id="id_thisusername" type="text" name="thisusername"
> maxlength="20" />
> - i get a writable input field
>
> when i try ....
> <input id="thisusername" type="text" name="thisusername"
> maxlength="20" READONLY />
> - i get a blank input / no value field
>
> How does Django enable the ability to pass variables to a Form or a
> Template whose purpose is only to be displayed?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---