A `related thing`__ came up on the Django Dev list this week. I'm not that old-school. :-) I use that `{% if user.is_authenticated %}` all over my site and it's a pain to import and call all the stuff you need for render_to_response over and over. So this is what I changed all my views to this week::
from django.views.generic.simple import direct_to_template def my_view(self): return direct_to_template(request, 'my_template.html', { 'extra-context': 'goes here', }) .. __: http://groups.google.com/group/django-developers/browse_thread/thread/e0a59d1eaa84c7b4/# - whiteinge On Jun 29, 12:13 pm, "Jeremy Dunck" <[EMAIL PROTECTED]> wrote: > On 6/29/07, Kirk Strauser <[EMAIL PROTECTED]> wrote: > ... > > > return render_to_response('index.html', > > context_instance=RequestContext(request)) > ... > > > My only concern is that it would seem that I'll need to manually build and > > pass in a RequestContext for every single view, since I want to have a login > > or logout link at the top of each one. Is that correct? > > render_to_response(template_name, context_instance=None, **kwargs) is > a shortcut over this: > > t = get_template(template_name) > c = context_instance or Context() > c.update(kwargs) > return HttpResponse(t.render(c)) > > So passing in context_instance is still shorter. > > If you still don't like it, you could use > django.views.generic.direct_to_template as the last line instead of > render_to_response. > > I guess I'm old school-- I still generally use the longer form. :) --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---