Is it possible to pass more than 1 argument to a context processor in Django? In other words, in addition to the HttpRequest object, I would like to pass 1 or more additional argument?
A:
You might want to look into custom tags:
http://docs.djangoproject.com/en/dev/howto/custom-template-tags/#howto-custom-template-tags
Make sure that your template tags module is in a templatetags
subdir of a loaded module. I.e. if you have a "foo" module in your INSTALLED_APPS
, make sure that, wherever foo is located, there is a:
foo/templatetags/blurf.py
that contains the tags and filters you want. Then you can:
{% load blurf %}
in your template, and if blurf has a grok
tag with two arguments defined, then you can:
{% grok 1 2 %}
in that template.
eruciform
2010-07-18 22:01:07
@sizeight: did you end up using templatetags?
eruciform
2010-07-28 20:48:55
+2
A:
Store whatever variables you would want in the session. Then you can access it through the request.
Zach
2010-07-19 03:08:28
This was exactly my thought. It's dead simple and doesn't require anything to be modified.
Peter Rowell
2010-07-19 05:04:22