diff options
| author | Adrian Holovaty <adrian@holovaty.com> | 2006-01-12 04:41:23 +0000 |
|---|---|---|
| committer | Adrian Holovaty <adrian@holovaty.com> | 2006-01-12 04:41:23 +0000 |
| commit | 6a0ba52223334491532dd8f878192f29d36c3e3d (patch) | |
| tree | e84c0f26c938e5134d5856b23d30de73bd9ac3d7 /docs | |
| parent | b125cafbfc715f808b8af6125a1c1dddc7079963 (diff) | |
Removed 'Subclassing Context: Custom subclasses' from docs/templates_python.txt because the same thing can be accomplished using DjangoContext processors
git-svn-id: http://code.djangoproject.com/svn/django/trunk@1924 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/templates_python.txt | 22 |
1 files changed, 0 insertions, 22 deletions
diff --git a/docs/templates_python.txt b/docs/templates_python.txt index fcb6a22230..b72a5085a2 100644 --- a/docs/templates_python.txt +++ b/docs/templates_python.txt @@ -329,28 +329,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.core.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 ----------------- |
