Index: django/template/__init__.py
===================================================================
--- django/template/__init__.py	(revision 11683)
+++ django/template/__init__.py	(working copy)
@@ -566,7 +566,9 @@
                     arg_vals.append(mark_safe(arg))
                 else:
                     arg_vals.append(arg.resolve(context))
-            if getattr(func, 'needs_autoescape', False):
+            if getattr(func, 'needs_context', False):
+                new_obj = func(obj, context=context, *arg_vals)
+            elif getattr(func, 'needs_autoescape', False):
                 new_obj = func(obj, autoescape=context.autoescape, *arg_vals)
             else:
                 new_obj = func(obj, *arg_vals)
@@ -801,7 +803,7 @@
 
     def render(self, context):
         return self.s
-    
+
 def _render_value_in_context(value, context):
     """
     Converts any value to a string to become part of a rendered template. This
Index: docs/howto/custom-template-tags.txt
===================================================================
--- docs/howto/custom-template-tags.txt	(revision 11683)
+++ docs/howto/custom-template-tags.txt	(working copy)
@@ -305,6 +305,28 @@
        handle the auto-escaping issues and return a safe string, the
        ``is_safe`` attribute won't change anything either way.
 
+Context filters
+~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. versionadded:: 1.2
+
+Filters can behave diffrently depending on context. To make your filter get
+context, set the ``needs_context`` attribute to ``True`` on your function
+For example, this filter will transform given time to time zone specified
+in context:
+
+    import pytz
+    from django.conf import settings
+
+    def localtime(dt, context=None):
+        if dt.tzinfo is None:
+            dt = pytz.timezone(settings.TIME_ZONE).localize(dt)
+        return dt.astimezone(context['timezone'])
+    localtime.needs_context = True
+
+Of course, the 'timezone' key should be written into context to use it.
+Also, you can't use both ``needs_context`` and ``needs_autoescape``.
+
 Writing custom template tags
 ----------------------------
 
