On Monday 05 June 2006 20:02, Spock wrote: > ------ > from django.template import RequestContext as Context > from django.shortcuts import render_to_response > > > def index(request): > ..[cut bla bla ].. > return render_to_response('helpdesk/ticket_list.html', > Context(request,{'object_list':t})) > ------ > > Is there any "DRY"(shorter) method for this Context(request,{}) > _every_time ? :)
I understand what you mean, but really, if you want the template system to have access to something in the request, you simply *have* to pass it through -- there's no getting around passing arguments to functions. [Except, of course, there is: you could create a custom Context class which inherits from the RequestContext and overloads its __init__, inside of which you use either sys._getframe hacks (fragile) or threadlocal storage (more robust, but would require writing a middleware to do the necessary setup) to pass the request object implicitly. It obfuscates your code, and for this saving I wouldn't have thought it worth it. I personally do use threadlocal storage to make the currently logged in user available to various model methods, since there is no other way to do this.] Luke -- "Whoever calls on the name of the LORD will be saved." (Romans 10:13) Luke Plant || L.Plant.98 (at) cantab.net || http://lukeplant.me.uk/ --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---