Changeset 1951
- Timestamp:
- 01/13/06 12:27:40 (3 years ago)
- Files:
-
- django/branches/magic-removal/docs/authentication.txt (modified) (3 diffs)
- django/branches/magic-removal/docs/flatpages.txt (modified) (2 diffs)
- django/branches/magic-removal/docs/generic_views.txt (modified) (1 diff)
- django/branches/magic-removal/docs/i18n.txt (modified) (2 diffs)
- django/branches/magic-removal/docs/settings.txt (modified) (3 diffs)
- django/branches/magic-removal/docs/templates_python.txt (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/magic-removal/docs/authentication.txt
r1916 r1951 436 436 437 437 The currently logged-in user and his/her permissions are made available in the 438 `template context`_ when you use `` DjangoContext``.438 `template context`_ when you use ``RequestContext``. 439 439 440 440 .. admonition:: Technicality 441 441 442 442 Technically, these variables are only made available in the template context 443 if you use `` DjangoContext`` *and* your ``TEMPLATE_CONTEXT_PROCESSORS``443 if you use ``RequestContext`` *and* your ``TEMPLATE_CONTEXT_PROCESSORS`` 444 444 setting contains ``"django.core.context_processors.auth"``, which is default. 445 For more, see the ` DjangoContext docs`_.446 447 .. _ DjangoContext docs: http://www.djangoproject.com/documentation/templates_python/#subclassing-context-djangocontext445 For more, see the `RequestContext docs`_. 446 447 .. _RequestContext docs: http://www.djangoproject.com/documentation/templates_python/#subclassing-context-djangocontext 448 448 449 449 Users … … 534 534 # ... 535 535 request.user.add_message("Your playlist was added successfully.") 536 return render_to_response("playlists/create", context_instance= DjangoContext(request))537 538 When you use `` DjangoContext``, the currently logged-in user and his/her536 return render_to_response("playlists/create", context_instance=RequestContext(request)) 537 538 When you use ``RequestContext``, the currently logged-in user and his/her 539 539 messages are made available in the `template context`_ as the template variable 540 540 ``{{ messages }}``. Here's an example of template code that displays messages:: … … 548 548 {% endif %} 549 549 550 Note that `` DjangoContext`` calls ``get_and_delete_messages`` behind the550 Note that ``RequestContext`` calls ``get_and_delete_messages`` behind the 551 551 scenes, so any messages will be deleted even if you don't display them. 552 552 django/branches/magic-removal/docs/flatpages.txt
r1166 r1951 50 50 it loads the template ``flatpages/default``. 51 51 * It passes that template a single context variable, ``flatpage``, which is 52 the flatpage object. It uses DjangoContext_ in rendering the template.52 the flatpage object. It uses RequestContext_ in rendering the template. 53 53 54 54 If it doesn't find a match, the request continues to be processed as usual. … … 64 64 65 65 .. _SITE_ID: http://www.djangoproject.com/documentation/settings/#site-id 66 .. _ DjangoContext: http://www.djangoproject.com/documentation/templates_python/#subclassing-context-djangocontext66 .. _RequestContext: http://www.djangoproject.com/documentation/templates_python/#subclassing-context-djangocontext 67 67 .. _middleware docs: http://www.djangoproject.com/documentation/middleware/ 68 68 django/branches/magic-removal/docs/generic_views.txt
r1933 r1951 122 122 123 123 ``processors`` A tuple of processors to apply to the 124 `` DjangoContext`` of this view's template. See the125 ` DjangoContext docs`_124 ``RequestContext`` of this view's template. See the 125 `RequestContext docs`_ 126 126 ======================= ================================================== 127 127 128 128 .. _database API docs: http://www.djangoproject.com/documentation/db_api/ 129 .. _ DjangoContext docs: http://www.djangoproject.com/documentation/templates_python/#subclassing-context-djangocontext129 .. _RequestContext docs: http://www.djangoproject.com/documentation/templates_python/#subclassing-context-djangocontext 130 130 131 131 The date-based generic functions are: 132 132 133 ``archive_index`` 133 ``archive_index``RequestContext 134 134 A top-level index page showing the "latest" objects. 135 135 django/branches/magic-removal/docs/i18n.txt
r1936 r1951 225 225 ``gettext`` / ``ngettext`` call. 226 226 227 Each `` DjangoContext`` has access to two translation-specific variables:227 Each ``RequestContext`` has access to two translation-specific variables: 228 228 229 229 * ``LANGUAGES`` is a list of tuples in which the first element is the … … 232 232 Example: ``en-us``. (See "How language preference is discovered", below.) 233 233 234 If you don't use the `` DjangoContext`` extension, you can get those values with234 If you don't use the ``RequestContext`` extension, you can get those values with 235 235 two tags:: 236 236 django/branches/magic-removal/docs/settings.txt
r1936 r1951 464 464 Default:: 465 465 466 ("django. contrib.sessions.middleware.SessionMiddleware",466 ("django.middleware.sessions.SessionMiddleware", 467 467 "django.middleware.common.CommonMiddleware", 468 468 "django.middleware.doc.XViewMiddleware") … … 556 556 "django.core.context_processors.i18n") 557 557 558 A tuple of callables that are used to populate the context in `` DjangoContext``.558 A tuple of callables that are used to populate the context in ``RequestContext``. 559 559 These callables take a request object as their argument and return a dictionary 560 560 of items to be merged into the context. … … 596 596 ---------------- 597 597 598 Default: ``('django. core.template.loaders.filesystem.load_template_source',)``598 Default: ``('django.template.loaders.filesystem.load_template_source',)`` 599 599 600 600 A tuple of callables (as strings) that know how to import templates from django/branches/magic-removal/docs/templates_python.txt
r1948 r1951 242 242 you'll see below. 243 243 244 Subclassing Context: DjangoContext244 Subclassing Context: RequestContext 245 245 ---------------------------------- 246 246 247 247 Django comes with a special ``Context`` class, 248 ``django. core.extensions.DjangoContext``, that acts slightly differently than248 ``django.template.RequestContext``, that acts slightly differently than 249 249 the normal ``django.template.Context``. The first difference is that takes 250 250 an `HttpRequest object`_ as its first argument. For example:: 251 251 252 c = DjangoContext(request, {252 c = RequestContext(request, { 253 253 'foo': 'bar', 254 254 } … … 270 270 below. 271 271 272 Also, you can give `` DjangoContext`` a list of additional processors, using the272 Also, you can give ``RequestContext`` a list of additional processors, using the 273 273 optional, third positional argument, ``processors``. In this example, the 274 `` DjangoContext`` instance gets a ``ip_address`` variable::274 ``RequestContext`` instance gets a ``ip_address`` variable:: 275 275 276 276 def ip_address_processor(request): … … 279 279 def some_view(request): 280 280 # ... 281 return DjangoContext({281 return RequestContext({ 282 282 'foo': 'bar', 283 283 }, [ip_address_processor]) … … 292 292 293 293 If ``TEMPLATE_CONTEXT_PROCESSORS`` contains this processor, every 294 `` DjangoContext`` will contain these three variables:294 ``RequestContext`` will contain these three variables: 295 295 296 296 * ``user`` -- An ``auth.User`` instance representing the currently … … 310 310 311 311 If ``TEMPLATE_CONTEXT_PROCESSORS`` contains this processor, every 312 `` DjangoContext`` will contain these two variables -- but only if your312 ``RequestContext`` will contain these two variables -- but only if your 313 313 ``DEBUG`` setting is set to ``True`` and the request's IP address 314 314 (``request.META['REMOTE_ADDR']``) is in the ``INTERNAL_IPS`` setting: … … 324 324 325 325 If ``TEMPLATE_CONTEXT_PROCESSORS`` contains this processor, every 326 `` DjangoContext`` will contain these two variables:326 ``RequestContext`` will contain these two variables: 327 327 328 328 * ``LANGUAGES`` -- The value of the `LANGUAGES setting`_.
