I wanted to do "blah" in context in a custom tag and found it didn't
work. I patched django.core.templates.Context, adding a __contains__
method. The patch is below. I didn't want to raise a ticket for this
as I'm not familiar with the other bits that are going on with the
class, or even sure that I've patched the right class. Should this go
in DjangoContext, for example?
Anyway, hope this is helpful.
Index: django/core/template/__init__.py
===================================================================
--- django/core/template/__init__.py (revision 1612)
+++ django/core/template/__init__.py (working copy)
@@ -183,6 +183,12 @@
return dict[key]
return ''
+ def __contains__(self, key):
+ for dict in self.dicts:
+ if dict.has_key(key):
+ return True
+ return False
+
def __delitem__(self, key):
"Delete a variable from the current context"
del self.dicts[0][key]
________________________________
Afternoon, man about the Internet -- http://aftnn.org/