Re: Access to request from tag

2010-12-26 Thread Mikhail Korobov
Hi Igor, If you use django <= 1.2 the you can replace 'render_to_response' with 'direct_to_template'. They do almost the same but 'direct_to_template' uses RequestContext by default: from django.views.generic.simple import direct_to_template def my_view(request): # ... return

Re: Access to request from tag

2010-12-26 Thread Igor Artamonov
BTW, thank you very much. I googled a lot, and decided that easiest way is replace all my "Context(" with "RequestContext(request," and use official way. That works :) -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group,

Re: Access to request from tag

2010-12-26 Thread PeteDK
Ahh my bad. didn't see the last part of your post where you said you had already tried the processor way :) however the docs. mention thread safety concerns when it comes to custom tags. http://docs.djangoproject.com/en/dev/howto/custom-template-tags/#thread-safety-considerations So perhabs it's

Re: Access to request from tag

2010-12-26 Thread Igor Artamonov
Yes, thank you Pete, but i know about this way. And it requires to use RequestContext class on _every_ view. I have too much of them, and also it makes boilerplate code. So, i'm looking for less complicated way. Maybe there is exist some way to use RequestContext by default? -- You received

Re: Access to request from tag

2010-12-26 Thread PeteDK
didn't mean to spam your thread… thought my answer was lost… :-S On 26 Dec., 10:57, PeteDK wrote: > Hi. > > You can use template context processors. > > http://docs.djangoproject.com/en/dev/ref/templates/api/#subclassing-c... > > you can either use the built in processors

Re: Access to request from tag

2010-12-26 Thread PeteDK
Hi. You can use template context processors. http://docs.djangoproject.com/en/dev/ref/templates/api/#subclassing-context-requestcontext you can either use the built in processors or write your own. They just have to be added in the settings file(all this is explained in the docs) These can

Re: Access to request from tag

2010-12-26 Thread PeteDK
Hi. You want to look at template context processors. http://docs.djangoproject.com/en/dev/ref/templates/api/#subclassing-context-requestcontext You can create your own context processors or use the built in. These can provide access to the current request in your template… and therefore

Access to request from tag

2010-12-26 Thread Igor Artamonov
Hi I need to make an custom tag, for auth checks, based on data stored on cookies. Like a: {% if_loggen_in %} Some message for logged in only user {% end_if_logged_in %} btw, i don't know how to get access to request object in my tag. I know that there is 'inclusion tags', but as you see there