tags:

views:

40

answers:

2

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
@sizeight: did you end up using templatetags?
eruciform
+2  A: 

Store whatever variables you would want in the session. Then you can access it through the request.

Zach
This was exactly my thought. It's dead simple and doesn't require anything to be modified.
Peter Rowell