thisusername = str(request.user.username)
data = {'thisusername':username,}
form = form_class(data)

shouldn't this be data={'thisusername':thisusername,} or
{'thisusername': str(request.user.username)}


On Mon, Mar 16, 2009 at 2:14 PM, NoviceSortOf <dljonsson2...@gmail.com> wrote:
>
> Thanks for your responses, they have helped.
>
> I've read the documentation many times, and only resort to groups
> after re-reading what I can find in the docs, testing various logical
> solutions, digging through groups and finally confering with a 3rd
> party book I've here on Django. If all else fails,
> then I post to groups.
>
> So that is why I'm puzzled when {{ var }} does not present var on my
> form.
>
> As mentioned above in views.py I'm passing data to the form_class in
> this example I'm using str to convert value to string.
>
> in view.py then
> ...
> thisusername = str(request.user.username)
> data = {'thisusername':username,}
> form = form_class(data)
>
> Now it seems form_class() would be adding the data to
> itself with form_class(data) but it isn't.
>
> Instead I have to add the context to the render_to_response
> despite the fact that this data has been added to form
> earlier.
>
> ie.
> return render_to_response(template_name, { 'form': form},
>                              context_instance=context)
>
> will either not display the item, or force it to be viewed
> only as a corresponding writable field as defined in forms.py
> or model.py.
>
> but loading it directly to render_to_response works...
>
> return render_to_response(template_name, { 'form': form,
> 'thisusername':username},
> context_instance=context)
>
> So perhaps a better question would be is
>
> in view.py...
> -----------
> thisusername = str(request.user.username)
> data = {'thisusername':username,}
> form = form_class(data)
>
> Why is it form_class(data) does not accept the data
> as declared and enable it to presented it in
> templates in any other form than a writable field
>  --  when render_to_response allows the data to be
>     presented as a string?
>
> >
>

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