1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

magic-removal: Merged to [1960]

git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@1961 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Adrian Holovaty
2006-01-15 00:14:41 +00:00
parent 3d293b5144
commit 0b5043832b
70 changed files with 1066 additions and 738 deletions

View File

@@ -278,7 +278,7 @@ optional, third positional argument, ``processors``. In this example, the
def some_view(request):
# ...
return RequestContext({
return RequestContext(request, {
'foo': 'bar',
}, [ip_address_processor])
@@ -335,28 +335,6 @@ See the `internationalization docs`_ for more.
.. _LANGUAGE_CODE setting: http://www.djangoproject.com/documentation/settings/#language-code
.. _internationalization docs: http://www.djangoproject.com/documentation/i18n/
Subclassing Context: Custom subclasses
--------------------------------------
Feel free to subclass ``Context`` yourself if you find yourself wanting to give
each template something "automatically." For instance, if you want to give
every template automatic access to the current time, use something like this::
from django.template import Context
import datetime
class TimeContext(Context):
def __init__(self, *args, **kwargs):
Context.__init__(self, *args, **kwargs)
self['current_time'] = datetime.datetime.now()
This technique has two caveats:
* You'll have to remember to use ``TimeContext`` instead of ``Context`` in
your template-loading code.
* You'll have to be careful not to set the variable ``current_time`` when
you populate this context. If you do, you'll override the other one.
Loading templates
-----------------