Re: How do I add the user ID to a template?

2008-06-24 Thread Eric Abrahamsen
If you do go the RequestContext route, you can wrap the standard render_to_response function in a custom render function that adds the RequestContext automatically, as per here: http://www.djangosnippets.org/snippets/3/ and then use the custom function in your views, instead of

Re: How do I add the user ID to a template?

2008-06-24 Thread Huuuze
I understand that. However, I was hoping that the Django FRAMEWORK would provide some easy mechanism for plucking that information out of the session (rather than the request). Many frameworks provide easy methods for doing so and, guessing by your response, Django does not provide not provide

Re: How do I add the user ID to a template?

2008-06-24 Thread Richard Dahl
The 'core' problem as you say, is essentially the core problem of all programming: programs don't write themselves. You have to write appropriate code for what you are trying to do, what does it matter if someone forgets to add the username to the render call, or if someone forgets to add the

Re: How do I add the user ID to a template?

2008-06-24 Thread Huuuze
Correct me if I'm wrong, but I'm not sure this resolves the core problem. In your example, I still need to add something (in this case, 'context_instance=RequestContext(request)') to my "render_to_response" statements. I'd like to eliminate that completely since it requires a developer to add

Re: How do I add the user ID to a template?

2008-06-24 Thread Richard Dahl
That (or some variation) is the simplest way to do it, although you do not need to attach the entire request object if you do not want to, i.e.: return render_to_response('somepage.html', {'username':request.user.username}) {{ username }} On 6/24/08, Huuuze <[EMAIL PROTECTED]> wrote: > > > A

Re: How do I add the user ID to a template?

2008-06-24 Thread Matthias Kestenholz
On Tue, 2008-06-24 at 06:47 -0700, Huuuze wrote: > A n00b question for everyone: My base template has a "Welcome > " section in it. Currently, I'm adding the username (which > is coming from Django's auth/auth framework) to the template with the > following bit of code: > > {{

Re: How do I add the user ID to a template?

2008-06-24 Thread Johan Liseborn
On Tue, Jun 24, 2008 at 15:47, Huuuze <[EMAIL PROTECTED]> wrote: > > A n00b question for everyone: My base template has a "Welcome > " section in it. Currently, I'm adding the username (which > is coming from Django's auth/auth framework) to the template with the > following bit of code: > > {{

How do I add the user ID to a template?

2008-06-24 Thread Huuuze
A n00b question for everyone: My base template has a "Welcome " section in it. Currently, I'm adding the username (which is coming from Django's auth/auth framework) to the template with the following bit of code: {{ request.session.user.username }} This works, however, it requires me to add