On Mar 16, 5:15 pm, NoviceSortOf <dljonsson2...@gmail.com> 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?
Have you thought that maybe it isn't Django that has the inability, when it comes to doing something as fundamental as displaying variables in a template? For a start, you haven't showed us what you are passing to the template, or why you think this has anything to do with forms. However, a simple reading of the documentation would show that Django's templates allow you to display any variable you pass using the {{ var }} syntax. So, for example, if you did this in your view: return render_to_response(template_name, {'username': username}) then you can do: {{ username }} to output the value of username. -- DR. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---