-
diff --git a/docs/faq/admin.txt b/docs/faq/admin.txt
|
a
|
b
|
|
| 10 | 10 | sent out by Django doesn't match the domain in your browser. Try these two |
| 11 | 11 | things: |
| 12 | 12 | |
| 13 | | * Set the ``SESSION_COOKIE_DOMAIN`` setting in your admin config file |
| | 13 | * Set the :setting:`SESSION_COOKIE_DOMAIN` setting in your admin config file |
| 14 | 14 | to match your domain. For example, if you're going to |
| 15 | 15 | "http://www.example.com/admin/" in your browser, in |
| 16 | 16 | "myproject.settings" you should set ``SESSION_COOKIE_DOMAIN = 'www.example.com'``. |
| … |
… |
|
| 19 | 19 | don't have dots in them. If you're running the admin site on "localhost" |
| 20 | 20 | or another domain that doesn't have a dot in it, try going to |
| 21 | 21 | "localhost.localdomain" or "127.0.0.1". And set |
| 22 | | ``SESSION_COOKIE_DOMAIN`` accordingly. |
| | 22 | :setting:`SESSION_COOKIE_DOMAIN` accordingly. |
| 23 | 23 | |
| 24 | 24 | I can't log in. When I enter a valid username and password, it brings up the login page again, with a "Please enter a correct username and password" error. |
| 25 | 25 | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
-
diff --git a/docs/faq/models.txt b/docs/faq/models.txt
|
a
|
b
|
|
| 6 | 6 | How can I see the raw SQL queries Django is running? |
| 7 | 7 | ---------------------------------------------------- |
| 8 | 8 | |
| 9 | | Make sure your Django ``DEBUG`` setting is set to ``True``. Then, just do |
| | 9 | Make sure your Django :setting:`DEBUG` setting is set to ``True``. Then, just do |
| 10 | 10 | this:: |
| 11 | 11 | |
| 12 | 12 | >>> from django.db import connection |
| … |
… |
|
| 14 | 14 | [{'sql': 'SELECT polls_polls.id,polls_polls.question,polls_polls.pub_date FROM polls_polls', |
| 15 | 15 | 'time': '0.002'}] |
| 16 | 16 | |
| 17 | | ``connection.queries`` is only available if ``DEBUG`` is ``True``. It's a list |
| | 17 | ``connection.queries`` is only available if :setting:`DEBUG` is ``True``. It's a list |
| 18 | 18 | of dictionaries in order of query execution. Each dictionary has the following:: |
| 19 | 19 | |
| 20 | 20 | ``sql`` -- The raw SQL statement |
| … |
… |
|
| 79 | 79 | |
| 80 | 80 | Django isn't known to leak memory. If you find your Django processes are |
| 81 | 81 | allocating more and more memory, with no sign of releasing it, check to make |
| 82 | | sure your ``DEBUG`` setting is set to ``True``. If ``DEBUG`` is ``True``, then |
| | 82 | sure your :setting:`DEBUG` setting is set to ``True``. If :setting:`DEBUG` is ``True``, then |
| 83 | 83 | Django saves a copy of every SQL statement it has executed. |
| 84 | 84 | |
| 85 | 85 | (The queries are saved in ``django.db.connection.queries``. See |
| 86 | 86 | `How can I see the raw SQL queries Django is running?`_.) |
| 87 | 87 | |
| 88 | | To fix the problem, set ``DEBUG`` to ``False``. |
| | 88 | To fix the problem, set :setting:`DEBUG` to ``False``. |
| 89 | 89 | |
| 90 | 90 | If you need to clear the query list manually at any point in your functions, |
| 91 | 91 | just call ``reset_queries()``, like this:: |
-
diff --git a/docs/howto/deployment/fastcgi.txt b/docs/howto/deployment/fastcgi.txt
|
a
|
b
|
|
| 371 | 371 | |
| 372 | 372 | In the cases where Django cannot work out the prefix correctly and where you |
| 373 | 373 | want the original value to be used in URLs, you can set the |
| 374 | | ``FORCE_SCRIPT_NAME`` setting in your main ``settings`` file. This sets the |
| | 374 | :setting:`FORCE_SCRIPT_NAME` setting in your main ``settings`` file. This sets the |
| 375 | 375 | script name uniformly for every URL served via that settings file. Thus you'll |
| 376 | 376 | need to use different settings files if you want different sets of URLs to |
| 377 | 377 | have different script names in this case, but that is a rare situation. |
-
diff --git a/docs/internals/contributing.txt b/docs/internals/contributing.txt
|
a
|
b
|
|
| 752 | 752 | ./runtests.py --settings=path.to.django.settings |
| 753 | 753 | |
| 754 | 754 | Yes, the unit tests need a settings module, but only for database connection |
| 755 | | info, with the ``DATABASE_ENGINE`` setting. |
| | 755 | info, with the :setting:`DATABASE_ENGINE` setting. |
| 756 | 756 | |
| 757 | 757 | If you're using the ``sqlite3`` database backend, no further settings are |
| 758 | 758 | needed. A temporary database will be created in memory when running the tests. |
| … |
… |
|
| 771 | 771 | |
| 772 | 772 | You will also need to ensure that your database uses UTF-8 as the default |
| 773 | 773 | character set. If your database server doesn't use UTF-8 as a default charset, |
| 774 | | you will need to include a value for ``TEST_DATABASE_CHARSET`` in your settings |
| | 774 | you will need to include a value for :setting:`TEST_DATABASE_CHARSET` in your settings |
| 775 | 775 | file. |
| 776 | 776 | |
| 777 | 777 | If you want to run the full suite of tests, you'll need to install a number of |
-
diff --git a/docs/intro/tutorial01.txt b/docs/intro/tutorial01.txt
|
a
|
b
|
|
| 158 | 158 | |
| 159 | 159 | * :setting:`DATABASE_NAME` -- The name of your database. If you're using |
| 160 | 160 | SQLite, the database will be a file on your computer; in that case, |
| 161 | | ``DATABASE_NAME`` should be the full absolute path, including filename, of |
| | 161 | :setting:`DATABASE_NAME` should be the full absolute path, including filename, of |
| 162 | 162 | that file. If the file doesn't exist, it will automatically be created |
| 163 | 163 | when you synchronize the database for the first time (see below). |
| 164 | 164 | |
-
diff --git a/docs/ref/contrib/admin.txt b/docs/ref/contrib/admin.txt
|
a
|
b
|
|
| 25 | 25 | |
| 26 | 26 | There are five steps in activating the Django admin site: |
| 27 | 27 | |
| 28 | | 1. Add ``django.contrib.admin`` to your ``INSTALLED_APPS`` setting. |
| | 28 | 1. Add ``django.contrib.admin`` to your :setting:`INSTALLED_APPS` setting. |
| 29 | 29 | |
| 30 | 30 | 2. Determine which of your application's models should be editable in the |
| 31 | 31 | admin interface. |
| … |
… |
|
| 646 | 646 | } |
| 647 | 647 | js = ("my_code.js",) |
| 648 | 648 | |
| 649 | | Keep in mind that this will be prepended with ``MEDIA_URL``. The same rules |
| | 649 | Keep in mind that this will be prepended with :setting:`MEDIA_URL`. The same rules |
| 650 | 650 | apply as :ref:`regular media definitions on forms <topics-forms-media>`. |
| 651 | 651 | |
| 652 | 652 | Adding custom validation to the admin |
| … |
… |
|
| 909 | 909 | |
| 910 | 910 | In order to override one or more of them, first create an ``admin`` directory in |
| 911 | 911 | your project's ``templates`` directory. This can be any of the directories you |
| 912 | | specified in ``TEMPLATE_DIRS``. |
| | 912 | specified in :setting:`TEMPLATE_DIRS`. |
| 913 | 913 | |
| 914 | 914 | Within this ``admin`` directory, create sub-directories named after your app. |
| 915 | 915 | Within these app subdirectories create sub-directories named after your models. |
| … |
… |
|
| 1031 | 1031 | ) |
| 1032 | 1032 | |
| 1033 | 1033 | Above we used ``admin.autodiscover()`` to automatically load the |
| 1034 | | ``INSTALLED_APPS`` admin.py modules. |
| | 1034 | :setting:`INSTALLED_APPS` admin.py modules. |
| 1035 | 1035 | |
| 1036 | 1036 | In this example, we register the ``AdminSite`` instance |
| 1037 | 1037 | ``myproject.admin.admin_site`` at the URL ``/myadmin/`` :: |
-
diff --git a/docs/ref/contrib/comments/settings.txt b/docs/ref/contrib/comments/settings.txt
|
a
|
b
|
|
| 29 | 29 | COMMENTS_APP |
| 30 | 30 | ------------ |
| 31 | 31 | |
| 32 | | The app (i.e. entry in ``INSTALLED_APPS``) responsible for all "business logic." |
| | 32 | The app (i.e. entry in :setting:`INSTALLED_APPS`) responsible for all "business logic." |
| 33 | 33 | You can change this to provide custom comment models and forms, though this is |
| 34 | 34 | currently undocumented. |
-
diff --git a/docs/ref/contrib/index.txt b/docs/ref/contrib/index.txt
|
a
|
b
|
|
| 16 | 16 | |
| 17 | 17 | For most of these add-ons -- specifically, the add-ons that include either |
| 18 | 18 | models or template tags -- you'll need to add the package name (e.g., |
| 19 | | ``'django.contrib.admin'``) to your ``INSTALLED_APPS`` setting and re-run |
| | 19 | ``'django.contrib.admin'``) to your :setting:`INSTALLED_APPS` setting and re-run |
| 20 | 20 | ``manage.py syncdb``. |
| 21 | 21 | |
| 22 | 22 | .. _"batteries included" philosophy: http://docs.python.org/tut/node12.html#batteries-included |
-
diff --git a/docs/ref/databases.txt b/docs/ref/databases.txt
|
a
|
b
|
|
| 173 | 173 | :setting:`DATABASE_PORT` |
| 174 | 174 | 3. MySQL option files. |
| 175 | 175 | |
| 176 | | In other words, if you set the name of the database in ``DATABASE_OPTIONS``, |
| 177 | | this will take precedence over ``DATABASE_NAME``, which would override |
| | 176 | In other words, if you set the name of the database in :setting:`DATABASE_OPTIONS`, |
| | 177 | this will take precedence over :setting:`DATABASE_NAME`, which would override |
| 178 | 178 | anything in a `MySQL option file`_. |
| 179 | 179 | |
| 180 | 180 | Here's a sample configuration which uses a MySQL option file:: |
-
diff --git a/docs/ref/django-admin.txt b/docs/ref/django-admin.txt
|
a
|
b
|
|
| 63 | 63 | --------- |
| 64 | 64 | |
| 65 | 65 | Many subcommands take a list of "app names." An "app name" is the basename of |
| 66 | | the package containing your models. For example, if your ``INSTALLED_APPS`` |
| | 66 | the package containing your models. For example, if your :setting:`INSTALLED_APPS` |
| 67 | 67 | contains the string ``'mysite.blog'``, the app name is ``blog``. |
| 68 | 68 | |
| 69 | 69 | Determining the version |
| … |
… |
|
| 160 | 160 | .. django-admin:: dbshell |
| 161 | 161 | |
| 162 | 162 | Runs the command-line client for the database engine specified in your |
| 163 | | ``DATABASE_ENGINE`` setting, with the connection parameters specified in your |
| 164 | | ``DATABASE_USER``, ``DATABASE_PASSWORD``, etc., settings. |
| | 163 | :setting:`DATABASE_ENGINE` setting, with the connection parameters specified in your |
| | 164 | :setting:`DATABASE_USER`, :setting:`DATABASE_PASSWORD`, etc., settings. |
| 165 | 165 | |
| 166 | 166 | * For PostgreSQL, this runs the ``psql`` command-line client. |
| 167 | 167 | * For MySQL, this runs the ``mysql`` command-line client. |
| … |
… |
|
| 181 | 181 | settings. |
| 182 | 182 | |
| 183 | 183 | Settings that don't appear in the defaults are followed by ``"###"``. For |
| 184 | | example, the default settings don't define ``ROOT_URLCONF``, so |
| 185 | | ``ROOT_URLCONF`` is followed by ``"###"`` in the output of ``diffsettings``. |
| | 184 | example, the default settings don't define :setting:`ROOT_URLCONF`, so |
| | 185 | :setting:`ROOT_URLCONF` is followed by ``"###"`` in the output of ``diffsettings``. |
| 186 | 186 | |
| 187 | 187 | Note that Django's default settings live in ``django/conf/global_settings.py``, |
| 188 | 188 | if you're ever curious to see the full list of defaults. |
| … |
… |
|
| 245 | 245 | The behavior of this command has changed in the Django development version. |
| 246 | 246 | Previously, this command cleared *every* table in the database, including any |
| 247 | 247 | table that Django didn't know about (i.e., tables that didn't have associated |
| 248 | | models and/or weren't in ``INSTALLED_APPS``). Now, the command only clears |
| | 248 | models and/or weren't in :setting:`INSTALLED_APPS`). Now, the command only clears |
| 249 | 249 | tables that are represented by Django models and are activated in |
| 250 | | ``INSTALLED_APPS``. |
| | 250 | :setting:`INSTALLED_APPS`. |
| 251 | 251 | |
| 252 | 252 | .. django-admin-option:: --noinput |
| 253 | 253 | |
| … |
… |
|
| 259 | 259 | --------- |
| 260 | 260 | |
| 261 | 261 | Introspects the database tables in the database pointed-to by the |
| 262 | | ``DATABASE_NAME`` setting and outputs a Django model module (a ``models.py`` |
| | 262 | :setting:`DATABASE_NAME` setting and outputs a Django model module (a ``models.py`` |
| 263 | 263 | file) to standard output. |
| 264 | 264 | |
| 265 | 265 | Use this if you have a legacy database with which you'd like to use Django. |
| … |
… |
|
| 308 | 308 | Django will search in three locations for fixtures: |
| 309 | 309 | |
| 310 | 310 | 1. In the ``fixtures`` directory of every installed application |
| 311 | | 2. In any directory named in the ``FIXTURE_DIRS`` setting |
| | 311 | 2. In any directory named in the :setting:`FIXTURE_DIRS` setting |
| 312 | 312 | 3. In the literal path named by the fixture |
| 313 | 313 | |
| 314 | 314 | Django will load any and all fixtures it finds in these locations that match |
| … |
… |
|
| 343 | 343 | |
| 344 | 344 | would search ``<appname>/fixtures/foo/bar/mydata.json`` for each installed |
| 345 | 345 | application, ``<dirname>/foo/bar/mydata.json`` for each directory in |
| 346 | | ``FIXTURE_DIRS``, and the literal path ``foo/bar/mydata.json``. |
| | 346 | :setting:`FIXTURE_DIRS`, and the literal path ``foo/bar/mydata.json``. |
| 347 | 347 | |
| 348 | 348 | Note that the order in which fixture files are processed is undefined. However, |
| 349 | 349 | all fixture data is installed as a single transaction, so data in |
| … |
… |
|
| 520 | 520 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 521 | 521 | |
| 522 | 522 | By default, the development server doesn't serve any static files for your site |
| 523 | | (such as CSS files, images, things under ``MEDIA_URL`` and so forth). If |
| | 523 | (such as CSS files, images, things under :setting:`MEDIA_URL` and so forth). If |
| 524 | 524 | you want to configure Django to serve static media, read :ref:`howto-static-files`. |
| 525 | 525 | |
| 526 | 526 | Turning off auto-reload |
| … |
… |
|
| 624 | 624 | syncdb |
| 625 | 625 | ------ |
| 626 | 626 | |
| 627 | | Creates the database tables for all apps in ``INSTALLED_APPS`` whose tables |
| | 627 | Creates the database tables for all apps in :setting:`INSTALLED_APPS` whose tables |
| 628 | 628 | have not already been created. |
| 629 | 629 | |
| 630 | 630 | Use this command when you've added new applications to your project and want to |
| 631 | 631 | install them in the database. This includes any apps shipped with Django that |
| 632 | | might be in ``INSTALLED_APPS`` by default. When you start a new project, run |
| | 632 | might be in :setting:`INSTALLED_APPS` by default. When you start a new project, run |
| 633 | 633 | this command to install the default apps. |
| 634 | 634 | |
| 635 | 635 | .. admonition:: Syncdb will not alter existing tables |
| … |
… |
|
| 736 | 736 | validate |
| 737 | 737 | -------- |
| 738 | 738 | |
| 739 | | Validates all installed models (according to the ``INSTALLED_APPS`` setting) |
| | 739 | Validates all installed models (according to the :setting:`INSTALLED_APPS` setting) |
| 740 | 740 | and prints validation errors to standard output. |
| 741 | 741 | |
| 742 | 742 | Default options |
-
diff --git a/docs/ref/forms/fields.txt b/docs/ref/forms/fields.txt
|
a
|
b
|
|
| 724 | 724 | .. attribute:: URLField.validator_user_agent |
| 725 | 725 | |
| 726 | 726 | String used as the user-agent used when checking for a URL's existence. |
| 727 | | Defaults to the value of the ``URL_VALIDATOR_USER_AGENT`` setting. |
| | 727 | Defaults to the value of the :setting:`URL_VALIDATOR_USER_AGENT` setting. |
| 728 | 728 | |
| 729 | 729 | Slightly complex built-in ``Field`` classes |
| 730 | 730 | ------------------------------------------- |
-
diff --git a/docs/ref/generic-views.txt b/docs/ref/generic-views.txt
|
a
|
b
|
|
| 97 | 97 | just before rendering the template. |
| 98 | 98 | |
| 99 | 99 | * ``mimetype``: The MIME type to use for the resulting document. Defaults |
| 100 | | to the value of the ``DEFAULT_CONTENT_TYPE`` setting. |
| | 100 | to the value of the :setting:`DEFAULT_CONTENT_TYPE` setting. |
| 101 | 101 | |
| 102 | 102 | **Example:** |
| 103 | 103 | |
| … |
… |
|
| 191 | 191 | the view's template. |
| 192 | 192 | |
| 193 | 193 | * ``mimetype``: The MIME type to use for the resulting document. Defaults |
| 194 | | to the value of the ``DEFAULT_CONTENT_TYPE`` setting. |
| | 194 | to the value of the :setting:`DEFAULT_CONTENT_TYPE` setting. |
| 195 | 195 | |
| 196 | 196 | * ``allow_future``: A boolean specifying whether to include "future" |
| 197 | 197 | objects on this page, where "future" means objects in which the field |
| … |
… |
|
| 288 | 288 | this is ``False``. |
| 289 | 289 | |
| 290 | 290 | * ``mimetype``: The MIME type to use for the resulting document. Defaults |
| 291 | | to the value of the ``DEFAULT_CONTENT_TYPE`` setting. |
| | 291 | to the value of the :setting:`DEFAULT_CONTENT_TYPE` setting. |
| 292 | 292 | |
| 293 | 293 | * ``allow_future``: A boolean specifying whether to include "future" |
| 294 | 294 | objects on this page, where "future" means objects in which the field |
| … |
… |
|
| 375 | 375 | determining the variable's name. |
| 376 | 376 | |
| 377 | 377 | * ``mimetype``: The MIME type to use for the resulting document. Defaults |
| 378 | | to the value of the ``DEFAULT_CONTENT_TYPE`` setting. |
| | 378 | to the value of the :setting:`DEFAULT_CONTENT_TYPE` setting. |
| 379 | 379 | |
| 380 | 380 | * ``allow_future``: A boolean specifying whether to include "future" |
| 381 | 381 | objects on this page, where "future" means objects in which the field |
| … |
… |
|
| 456 | 456 | determining the variable's name. |
| 457 | 457 | |
| 458 | 458 | * ``mimetype``: The MIME type to use for the resulting document. Defaults |
| 459 | | to the value of the ``DEFAULT_CONTENT_TYPE`` setting. |
| | 459 | to the value of the :setting:`DEFAULT_CONTENT_TYPE` setting. |
| 460 | 460 | |
| 461 | 461 | * ``allow_future``: A boolean specifying whether to include "future" |
| 462 | 462 | objects on this page, where "future" means objects in which the field |
| … |
… |
|
| 541 | 541 | determining the variable's name. |
| 542 | 542 | |
| 543 | 543 | * ``mimetype``: The MIME type to use for the resulting document. Defaults |
| 544 | | to the value of the ``DEFAULT_CONTENT_TYPE`` setting. |
| | 544 | to the value of the :setting:`DEFAULT_CONTENT_TYPE` setting. |
| 545 | 545 | |
| 546 | 546 | * ``allow_future``: A boolean specifying whether to include "future" |
| 547 | 547 | objects on this page, where "future" means objects in which the field |
| … |
… |
|
| 651 | 651 | to use in the template context. By default, this is ``'object'``. |
| 652 | 652 | |
| 653 | 653 | * ``mimetype``: The MIME type to use for the resulting document. Defaults |
| 654 | | to the value of the ``DEFAULT_CONTENT_TYPE`` setting. |
| | 654 | to the value of the :setting:`DEFAULT_CONTENT_TYPE` setting. |
| 655 | 655 | |
| 656 | 656 | * ``allow_future``: A boolean specifying whether to include "future" |
| 657 | 657 | objects on this page, where "future" means objects in which the field |
| … |
… |
|
| 727 | 727 | determining the variable's name. |
| 728 | 728 | |
| 729 | 729 | * ``mimetype``: The MIME type to use for the resulting document. Defaults |
| 730 | | to the value of the ``DEFAULT_CONTENT_TYPE`` setting. |
| | 730 | to the value of the :setting:`DEFAULT_CONTENT_TYPE` setting. |
| 731 | 731 | |
| 732 | 732 | **Template name:** |
| 733 | 733 | |
| … |
… |
|
| 846 | 846 | to use in the template context. By default, this is ``'object'``. |
| 847 | 847 | |
| 848 | 848 | * ``mimetype``: The MIME type to use for the resulting document. Defaults |
| 849 | | to the value of the ``DEFAULT_CONTENT_TYPE`` setting. |
| | 849 | to the value of the :setting:`DEFAULT_CONTENT_TYPE` setting. |
| 850 | 850 | |
| 851 | 851 | **Template name:** |
| 852 | 852 | |
-
diff --git a/docs/ref/request-response.txt b/docs/ref/request-response.txt
|
a
|
b
|
|
| 52 | 52 | .. versionadded:: 1.0 |
| 53 | 53 | |
| 54 | 54 | A string representing the current encoding used to decode form submission |
| 55 | | data (or ``None``, which means the ``DEFAULT_CHARSET`` setting is used). |
| | 55 | data (or ``None``, which means the :setting:`DEFAULT_CHARSET` setting is used). |
| 56 | 56 | You can write to this attribute to change the encoding used when accessing |
| 57 | 57 | the form data. Any subsequent attribute accesses (such as reading from |
| 58 | 58 | ``GET`` or ``POST``) will use the new ``encoding`` value. Useful if you |
| 59 | | know the form data is not in the ``DEFAULT_CHARSET`` encoding. |
| | 59 | know the form data is not in the :setting:`DEFAULT_CHARSET` encoding. |
| 60 | 60 | |
| 61 | 61 | .. attribute:: HttpRequest.GET |
| 62 | 62 | |
| … |
… |
|
| 174 | 174 | |
| 175 | 175 | Not defined by Django itself, but will be read if other code (e.g., a custom |
| 176 | 176 | middleware class) sets it. When present, this will be used as the root |
| 177 | | URLconf for the current request, overriding the ``ROOT_URLCONF`` setting. |
| | 177 | URLconf for the current request, overriding the :setting:`ROOT_URLCONF` setting. |
| 178 | 178 | See :ref:`how-django-processes-a-request` for details. |
| 179 | 179 | |
| 180 | 180 | Methods |
| … |
… |
|
| 447 | 447 | .. method:: HttpResponse.__init__(content='', mimetype=None, status=200, content_type=DEFAULT_CONTENT_TYPE) |
| 448 | 448 | |
| 449 | 449 | Instantiates an ``HttpResponse`` object with the given page content (a |
| 450 | | string) and MIME type. The ``DEFAULT_CONTENT_TYPE`` is ``'text/html'``. |
| | 450 | string) and MIME type. The :setting:`DEFAULT_CONTENT_TYPE` is ``'text/html'``. |
| 451 | 451 | |
| 452 | 452 | ``content`` can be an iterator or a string. If it's an iterator, it should |
| 453 | 453 | return strings, and those strings will be joined together to form the |
| … |
… |
|
| 463 | 463 | encoding, which makes it more than just a MIME type specification. |
| 464 | 464 | If ``mimetype`` is specified (not ``None``), that value is used. |
| 465 | 465 | Otherwise, ``content_type`` is used. If neither is given, the |
| 466 | | ``DEFAULT_CONTENT_TYPE`` setting is used. |
| | 466 | :setting:`DEFAULT_CONTENT_TYPE` setting is used. |
| 467 | 467 | |
| 468 | 468 | .. method:: HttpResponse.__setitem__(header, value) |
| 469 | 469 | |
-
diff --git a/docs/ref/templates/builtins.txt b/docs/ref/templates/builtins.txt
|
a
|
b
|
|
| 1587 | 1587 | =============================== |
| 1588 | 1588 | |
| 1589 | 1589 | Django comes with a couple of other template-tag libraries that you have to |
| 1590 | | enable explicitly in your ``INSTALLED_APPS`` setting and enable in your |
| | 1590 | enable explicitly in your :setting:`INSTALLED_APPS` setting and enable in your |
| 1591 | 1591 | template with the ``{% load %}`` tag. |
| 1592 | 1592 | |
| 1593 | 1593 | django.contrib.humanize |
-
diff --git a/docs/topics/cache.txt b/docs/topics/cache.txt
|
a
|
b
|
|
| 49 | 49 | or directly in memory. This is an important decision that affects your cache's |
| 50 | 50 | performance; yes, some cache types are faster than others. |
| 51 | 51 | |
| 52 | | Your cache preference goes in the ``CACHE_BACKEND`` setting in your settings |
| | 52 | Your cache preference goes in the :setting:`CACHE_BACKEND` setting in your settings |
| 53 | 53 | file. Here's an explanation of all available values for CACHE_BACKEND. |
| 54 | 54 | |
| 55 | 55 | Memcached |
| … |
… |
|
| 82 | 82 | (http://www.danga.com/memcached/) and get the Python bindings from the |
| 83 | 83 | "Client APIs" section. |
| 84 | 84 | |
| 85 | | To use Memcached with Django, set ``CACHE_BACKEND`` to |
| | 85 | To use Memcached with Django, set :setting:`CACHE_BACKEND` to |
| 86 | 86 | ``memcached://ip:port/``, where ``ip`` is the IP address of the Memcached |
| 87 | 87 | daemon and ``port`` is the port on which Memcached is running. |
| 88 | 88 | |
| … |
… |
|
| 92 | 92 | |
| 93 | 93 | One excellent feature of Memcached is its ability to share cache over multiple |
| 94 | 94 | servers. To take advantage of this feature, include all server addresses in |
| 95 | | ``CACHE_BACKEND``, separated by semicolons. In this example, the cache is |
| | 95 | :setting:`CACHE_BACKEND`, separated by semicolons. In this example, the cache is |
| 96 | 96 | shared over Memcached instances running on IP address 172.19.26.240 and |
| 97 | 97 | 172.19.26.242, both on port 11211:: |
| 98 | 98 | |
| … |
… |
|
| 120 | 120 | in your database that is in the proper format that Django's database-cache |
| 121 | 121 | system expects. |
| 122 | 122 | |
| 123 | | Once you've created that database table, set your ``CACHE_BACKEND`` setting to |
| | 123 | Once you've created that database table, set your :setting:`CACHE_BACKEND` setting to |
| 124 | 124 | ``"db://tablename"``, where ``tablename`` is the name of the database table. |
| 125 | 125 | In this example, the cache table's name is ``my_cache_table``:: |
| 126 | 126 | |
| … |
… |
|
| 132 | 132 | ------------------ |
| 133 | 133 | |
| 134 | 134 | To store cached items on a filesystem, use the ``"file://"`` cache type for |
| 135 | | ``CACHE_BACKEND``. For example, to store cached data in ``/var/tmp/django_cache``, |
| | 135 | :setting:`CACHE_BACKEND`. For example, to store cached data in ``/var/tmp/django_cache``, |
| 136 | 136 | use this setting:: |
| 137 | 137 | |
| 138 | 138 | CACHE_BACKEND = 'file:///var/tmp/django_cache' |
| … |
… |
|
| 156 | 156 | |
| 157 | 157 | If you want the speed advantages of in-memory caching but don't have the |
| 158 | 158 | capability of running Memcached, consider the local-memory cache backend. This |
| 159 | | cache is multi-process and thread-safe. To use it, set ``CACHE_BACKEND`` to |
| | 159 | cache is multi-process and thread-safe. To use it, set :setting:`CACHE_BACKEND` to |
| 160 | 160 | ``"locmem:///"``. For example:: |
| 161 | 161 | |
| 162 | 162 | CACHE_BACKEND = 'locmem:///' |
| … |
… |
|
| 176 | 176 | various places but a development/test environment on which you don't want to |
| 177 | 177 | cache. As a result, your development environment won't use caching and your |
| 178 | 178 | production environment still will. To activate dummy caching, set |
| 179 | | ``CACHE_BACKEND`` like so:: |
| | 179 | :setting:`CACHE_BACKEND` like so:: |
| 180 | 180 | |
| 181 | 181 | CACHE_BACKEND = 'dummy:///' |
| 182 | 182 | |
| … |
… |
|
| 188 | 188 | While Django includes support for a number of cache backends out-of-the-box, |
| 189 | 189 | sometimes you might want to use a customized cache backend. To use an external |
| 190 | 190 | cache backend with Django, use a Python import path as the scheme portion (the |
| 191 | | part before the initial colon) of the ``CACHE_BACKEND`` URI, like so:: |
| | 191 | part before the initial colon) of the :setting:`CACHE_BACKEND` URI, like so:: |
| 192 | 192 | |
| 193 | 193 | CACHE_BACKEND = 'path.to.backend://' |
| 194 | 194 | |
| … |
… |
|
| 204 | 204 | ----------------------- |
| 205 | 205 | |
| 206 | 206 | All caches may take arguments. They're given in query-string style on the |
| 207 | | ``CACHE_BACKEND`` setting. Valid arguments are: |
| | 207 | :setting:`CACHE_BACKEND` setting. Valid arguments are: |
| 208 | 208 | |
| 209 | 209 | timeout |
| 210 | 210 | Default timeout, in seconds, to use for the cache. Defaults to 5 |
| … |
… |
|
| 245 | 245 | entire site. You'll need to add |
| 246 | 246 | ``'django.middleware.cache.UpdateCacheMiddleware'`` and |
| 247 | 247 | ``'django.middleware.cache.FetchFromCacheMiddleware'`` to your |
| 248 | | ``MIDDLEWARE_CLASSES`` setting, as in this example:: |
| | 248 | :setting:`MIDDLEWARE_CLASSES` setting, as in this example:: |
| 249 | 249 | |
| 250 | 250 | MIDDLEWARE_CLASSES = ( |
| 251 | 251 | 'django.middleware.cache.UpdateCacheMiddleware', |
| … |
… |
|
| 261 | 261 | |
| 262 | 262 | Then, add the following required settings to your Django settings file: |
| 263 | 263 | |
| 264 | | * ``CACHE_MIDDLEWARE_SECONDS`` -- The number of seconds each page should be |
| | 264 | * :setting:`CACHE_MIDDLEWARE_SECONDS` -- The number of seconds each page should be |
| 265 | 265 | cached. |
| 266 | | * ``CACHE_MIDDLEWARE_KEY_PREFIX`` -- If the cache is shared across multiple |
| | 266 | * :setting:`CACHE_MIDDLEWARE_KEY_PREFIX` -- If the cache is shared across multiple |
| 267 | 267 | sites using the same Django installation, set this to the name of the site, |
| 268 | 268 | or some other string that is unique to this Django instance, to prevent key |
| 269 | 269 | collisions. Use an empty string if you don't care. |
| 270 | 270 | |
| 271 | 271 | The cache middleware caches every page that doesn't have GET or POST |
| 272 | | parameters. Optionally, if the ``CACHE_MIDDLEWARE_ANONYMOUS_ONLY`` setting is |
| | 272 | parameters. Optionally, if the :setting:`CACHE_MIDDLEWARE_ANONYMOUS_ONLY` setting is |
| 273 | 273 | ``True``, only anonymous requests (i.e., not those made by a logged-in user) |
| 274 | 274 | will be cached. This is a simple and effective way of disabling caching for any |
| 275 | 275 | user-specific pages (include Django's admin interface). Note that if you use |
| 276 | | ``CACHE_MIDDLEWARE_ANONYMOUS_ONLY``, you should make sure you've activated |
| | 276 | :setting:`CACHE_MIDDLEWARE_ANONYMOUS_ONLY`, you should make sure you've activated |
| 277 | 277 | ``AuthenticationMiddleware``. |
| 278 | 278 | |
| 279 | 279 | Additionally, the cache middleware automatically sets a few headers in each |
| … |
… |
|
| 282 | 282 | * Sets the ``Last-Modified`` header to the current date/time when a fresh |
| 283 | 283 | (uncached) version of the page is requested. |
| 284 | 284 | * Sets the ``Expires`` header to the current date/time plus the defined |
| 285 | | ``CACHE_MIDDLEWARE_SECONDS``. |
| | 285 | :setting:`CACHE_MIDDLEWARE_SECONDS`. |
| 286 | 286 | * Sets the ``Cache-Control`` header to give a max age for the page -- again, |
| 287 | | from the ``CACHE_MIDDLEWARE_SECONDS`` setting. |
| | 287 | from the :setting:`CACHE_MIDDLEWARE_SECONDS` setting. |
| 288 | 288 | |
| 289 | 289 | See :ref:`topics-http-middleware` for more on middleware. |
| 290 | 290 | |
| … |
… |
|
| 292 | 292 | |
| 293 | 293 | If a view sets its own cache expiry time (i.e. it has a ``max-age`` section in |
| 294 | 294 | its ``Cache-Control`` header) then the page will be cached until the expiry |
| 295 | | time, rather than ``CACHE_MIDDLEWARE_SECONDS``. Using the decorators in |
| | 295 | time, rather than :setting:`CACHE_MIDDLEWARE_SECONDS`. Using the decorators in |
| 296 | 296 | ``django.views.decorators.cache`` you can easily set a view's expiry time |
| 297 | 297 | (using the ``cache_control`` decorator) or disable caching for a view (using |
| 298 | 298 | the ``never_cache`` decorator). See the `using other headers`__ section for |
| … |
… |
|
| 377 | 377 | API to store objects in the cache with any level of granularity you like. |
| 378 | 378 | |
| 379 | 379 | The cache API is simple. The cache module, ``django.core.cache``, exports a |
| 380 | | ``cache`` object that's automatically created from the ``CACHE_BACKEND`` |
| | 380 | ``cache`` object that's automatically created from the :setting:`CACHE_BACKEND` |
| 381 | 381 | setting:: |
| 382 | 382 | |
| 383 | 383 | >>> from django.core.cache import cache |
| … |
… |
|
| 389 | 389 | 'hello, world!' |
| 390 | 390 | |
| 391 | 391 | The ``timeout_seconds`` argument is optional and defaults to the ``timeout`` |
| 392 | | argument in the ``CACHE_BACKEND`` setting (explained above). |
| | 392 | argument in the :setting:`CACHE_BACKEND` setting (explained above). |
| 393 | 393 | |
| 394 | 394 | If the object doesn't exist in the cache, ``cache.get()`` returns ``None``:: |
| 395 | 395 | |
| … |
… |
|
| 615 | 615 | For explanation of Cache-Control HTTP directives, see the `Cache-Control spec`_. |
| 616 | 616 | |
| 617 | 617 | (Note that the caching middleware already sets the cache header's max-age with |
| 618 | | the value of the ``CACHE_MIDDLEWARE_SETTINGS`` setting. If you use a custom |
| | 618 | the value of the :setting:`CACHE_MIDDLEWARE_SETTINGS` setting. If you use a custom |
| 619 | 619 | ``max_age`` in a ``cache_control`` decorator, the decorator will take |
| 620 | 620 | precedence, and the header values will be merged correctly.) |
| 621 | 621 | |
| … |
… |
|
| 647 | 647 | =========================== |
| 648 | 648 | |
| 649 | 649 | If you use caching middleware, it's important to put each half in the right |
| 650 | | place within the ``MIDDLEWARE_CLASSES`` setting. That's because the cache |
| | 650 | place within the :setting:`MIDDLEWARE_CLASSES` setting. That's because the cache |
| 651 | 651 | middleware needs to know which headers by which to vary the cache storage. |
| 652 | 652 | Middleware always adds something to the ``Vary`` response header when it can. |
| 653 | 653 | |
-
diff --git a/docs/topics/db/transactions.txt b/docs/topics/db/transactions.txt
|
a
|
b
|
|
| 32 | 32 | transactions. |
| 33 | 33 | |
| 34 | 34 | To activate this feature, just add the ``TransactionMiddleware`` middleware to |
| 35 | | your ``MIDDLEWARE_CLASSES`` setting:: |
| | 35 | your :setting:`MIDDLEWARE_CLASSES` setting:: |
| 36 | 36 | |
| 37 | 37 | MIDDLEWARE_CLASSES = ( |
| 38 | 38 | 'django.contrib.sessions.middleware.SessionMiddleware', |
| … |
… |
|
| 136 | 136 | ================================================= |
| 137 | 137 | |
| 138 | 138 | Control freaks can totally disable all transaction management by setting |
| 139 | | ``DISABLE_TRANSACTION_MANAGEMENT`` to ``True`` in the Django settings file. |
| | 139 | :setting:`DISABLE_TRANSACTION_MANAGEMENT` to ``True`` in the Django settings file. |
| 140 | 140 | |
| 141 | 141 | If you do this, Django won't provide any automatic transaction management |
| 142 | 142 | whatsoever. Middleware will no longer implicitly commit transactions, and |
-
diff --git a/docs/topics/email.txt b/docs/topics/email.txt
|
a
|
b
|
|
| 58 | 58 | possible exceptions, all of which are subclasses of ``SMTPException``. |
| 59 | 59 | * ``auth_user``: The optional username to use to authenticate to the SMTP |
| 60 | 60 | server. If this isn't provided, Django will use the value of the |
| 61 | | ``EMAIL_HOST_USER`` setting. |
| | 61 | :setting:`EMAIL_HOST_USER` setting. |
| 62 | 62 | * ``auth_password``: The optional password to use to authenticate to the |
| 63 | 63 | SMTP server. If this isn't provided, Django will use the value of the |
| 64 | | ``EMAIL_HOST_PASSWORD`` setting. |
| | 64 | :setting:`EMAIL_HOST_PASSWORD` setting. |
| 65 | 65 | |
| 66 | 66 | .. _smtplib docs: http://docs.python.org/library/smtplib.html |
| 67 | 67 | |
-
diff --git a/docs/topics/files.txt b/docs/topics/files.txt
|
a
|
b
|
|
| 125 | 125 | ====================== =================================================== |
| 126 | 126 | ``location`` Optional. Absolute path to the directory that will |
| 127 | 127 | hold the files. If omitted, it will be set to the |
| 128 | | value of your ``MEDIA_ROOT`` setting. |
| | 128 | value of your :setting:`MEDIA_ROOT` setting. |
| 129 | 129 | ``base_url`` Optional. URL that serves the files stored at this |
| 130 | 130 | location. If omitted, it will default to the value |
| 131 | | of your ``MEDIA_URL`` setting. |
| | 131 | of your :setting:`MEDIA_URL` setting. |
| 132 | 132 | ====================== =================================================== |
| 133 | 133 | |
| 134 | 134 | For example, the following code will store uploaded files under |
| 135 | | ``/media/photos`` regardless of what your ``MEDIA_ROOT`` setting is:: |
| | 135 | ``/media/photos`` regardless of what your :setting:`MEDIA_ROOT` setting is:: |
| 136 | 136 | |
| 137 | 137 | from django.db import models |
| 138 | 138 | from django.core.files.storage import FileSystemStorage |
-
diff --git a/docs/topics/http/file-uploads.txt b/docs/topics/http/file-uploads.txt
|
a
|
b
|
|
| 214 | 214 | |
| 215 | 215 | When a user uploads a file, Django passes off the file data to an *upload |
| 216 | 216 | handler* -- a small class that handles file data as it gets uploaded. Upload |
| 217 | | handlers are initially defined in the ``FILE_UPLOAD_HANDLERS`` setting, which |
| | 217 | handlers are initially defined in the :setting:`FILE_UPLOAD_HANDLERS` setting, which |
| 218 | 218 | defaults to:: |
| 219 | 219 | |
| 220 | 220 | ("django.core.files.uploadhandler.MemoryFileUploadHandler", |
| … |
… |
|
| 235 | 235 | Sometimes particular views require different upload behavior. In these cases, |
| 236 | 236 | you can override upload handlers on a per-request basis by modifying |
| 237 | 237 | ``request.upload_handlers``. By default, this list will contain the upload |
| 238 | | handlers given by ``FILE_UPLOAD_HANDLERS``, but you can modify the list as you |
| | 238 | handlers given by :setting:`FILE_UPLOAD_HANDLERS`, but you can modify the list as you |
| 239 | 239 | would any other list. |
| 240 | 240 | |
| 241 | 241 | For instance, suppose you've written a ``ProgressBarUploadHandler`` that |
-
diff --git a/docs/topics/http/sessions.txt b/docs/topics/http/sessions.txt
|
a
|
b
|
|
| 16 | 16 | |
| 17 | 17 | To enable session functionality, do the following: |
| 18 | 18 | |
| 19 | | * Edit the ``MIDDLEWARE_CLASSES`` setting and make sure |
| 20 | | ``MIDDLEWARE_CLASSES`` contains ``'django.contrib.sessions.middleware.SessionMiddleware'``. |
| | 19 | * Edit the :setting:`MIDDLEWARE_CLASSES` setting and make sure |
| | 20 | :setting:`MIDDLEWARE_CLASSES` contains ``'django.contrib.sessions.middleware.SessionMiddleware'``. |
| 21 | 21 | The default ``settings.py`` created by ``django-admin.py startproject`` has |
| 22 | 22 | ``SessionMiddleware`` activated. |
| 23 | 23 | |
| 24 | | * Add ``'django.contrib.sessions'`` to your ``INSTALLED_APPS`` setting, |
| | 24 | * Add ``'django.contrib.sessions'`` to your :setting:`INSTALLED_APPS` setting, |
| 25 | 25 | and run ``manage.py syncdb`` to install the single database table |
| 26 | 26 | that stores session data. |
| 27 | 27 | |
| … |
… |
|
| 30 | 30 | see `configuring the session engine`_. |
| 31 | 31 | |
| 32 | 32 | If you don't want to use sessions, you might as well remove the |
| 33 | | ``SessionMiddleware`` line from ``MIDDLEWARE_CLASSES`` and ``'django.contrib.sessions'`` |
| 34 | | from your ``INSTALLED_APPS``. It'll save you a small bit of overhead. |
| | 33 | ``SessionMiddleware`` line from :setting:`MIDDLEWARE_CLASSES` and ``'django.contrib.sessions'`` |
| | 34 | from your :setting:`INSTALLED_APPS`. It'll save you a small bit of overhead. |
| 35 | 35 | |
| 36 | 36 | Configuring the session engine |
| 37 | 37 | ============================== |
| … |
… |
|
| 46 | 46 | Using file-based sessions |
| 47 | 47 | ------------------------- |
| 48 | 48 | |
| 49 | | To use file-based sessions, set the ``SESSION_ENGINE`` setting to |
| | 49 | To use file-based sessions, set the :setting:`SESSION_ENGINE` setting to |
| 50 | 50 | ``"django.contrib.sessions.backends.file"``. |
| 51 | 51 | |
| 52 | | You might also want to set the ``SESSION_FILE_PATH`` setting (which defaults |
| | 52 | You might also want to set the :setting:`SESSION_FILE_PATH` setting (which defaults |
| 53 | 53 | to output from ``tempfile.gettempdir()``, most likely ``/tmp``) to control |
| 54 | 54 | where Django stores session files. Be sure to check that your Web server has |
| 55 | 55 | permissions to read and write to this location. |
| … |
… |
|
| 57 | 57 | Using cache-based sessions |
| 58 | 58 | -------------------------- |
| 59 | 59 | |
| 60 | | To store session data using Django's cache system, set ``SESSION_ENGINE`` |
| | 60 | To store session data using Django's cache system, set :setting:`SESSION_ENGINE` |
| 61 | 61 | to ``"django.contrib.sessions.backends.cache"``. You'll want to make sure |
| 62 | 62 | you've configured your cache; see the :ref:`cache documentation <topics-cache>` for details. |
| 63 | 63 | |
| … |
… |
|
| 324 | 324 | |
| 325 | 325 | request.session.modified = True |
| 326 | 326 | |
| 327 | | To change this default behavior, set the ``SESSION_SAVE_EVERY_REQUEST`` setting |
| 328 | | to ``True``. If ``SESSION_SAVE_EVERY_REQUEST`` is ``True``, Django will save |
| | 327 | To change this default behavior, set the :setting:`SESSION_SAVE_EVERY_REQUEST` setting |
| | 328 | to ``True``. If :setting:`SESSION_SAVE_EVERY_REQUEST` is ``True``, Django will save |
| 329 | 329 | the session to the database on every single request. |
| 330 | 330 | |
| 331 | 331 | Note that the session cookie is only sent when a session has been created or |
| 332 | | modified. If ``SESSION_SAVE_EVERY_REQUEST`` is ``True``, the session cookie |
| | 332 | modified. If :setting:`SESSION_SAVE_EVERY_REQUEST` is ``True``, the session cookie |
| 333 | 333 | will be sent on every request. |
| 334 | 334 | |
| 335 | 335 | Similarly, the ``expires`` part of a session cookie is updated each time the |
| … |
… |
|
| 339 | 339 | =============================================== |
| 340 | 340 | |
| 341 | 341 | You can control whether the session framework uses browser-length sessions vs. |
| 342 | | persistent sessions with the ``SESSION_EXPIRE_AT_BROWSER_CLOSE`` setting. |
| | 342 | persistent sessions with the :setting:`SESSION_EXPIRE_AT_BROWSER_CLOSE` setting. |
| 343 | 343 | |
| 344 | | By default, ``SESSION_EXPIRE_AT_BROWSER_CLOSE`` is set to ``False``, which |
| | 344 | By default, :setting:`SESSION_EXPIRE_AT_BROWSER_CLOSE` is set to ``False``, which |
| 345 | 345 | means session cookies will be stored in users' browsers for as long as |
| 346 | | ``SESSION_COOKIE_AGE``. Use this if you don't want people to have to log in |
| | 346 | :setting:`SESSION_COOKIE_AGE`. Use this if you don't want people to have to log in |
| 347 | 347 | every time they open a browser. |
| 348 | 348 | |
| 349 | | If ``SESSION_EXPIRE_AT_BROWSER_CLOSE`` is set to ``True``, Django will use |
| | 349 | If :setting:`SESSION_EXPIRE_AT_BROWSER_CLOSE` is set to ``True``, Django will use |
| 350 | 350 | browser-length cookies -- cookies that expire as soon as the user closes his or |
| 351 | 351 | her browser. Use this if you want people to have to log in every time they open |
| 352 | 352 | a browser. |
-
diff --git a/docs/topics/http/urls.txt b/docs/topics/http/urls.txt
|
a
|
b
|
|
| 37 | 37 | algorithm the system follows to determine which Python code to execute: |
| 38 | 38 | |
| 39 | 39 | 1. Django determines the root URLconf module to use. Ordinarily, |
| 40 | | this is the value of the ``ROOT_URLCONF`` setting, but if the incoming |
| | 40 | this is the value of the :setting:`ROOT_URLCONF` setting, but if the incoming |
| 41 | 41 | ``HttpRequest`` object has an attribute called ``urlconf``, its value |
| 42 | | will be used in place of the ``ROOT_URLCONF`` setting. |
| | 42 | will be used in place of the :setting:`ROOT_URLCONF` setting. |
| 43 | 43 | |
| 44 | 44 | 2. Django loads that Python module and looks for the variable |
| 45 | 45 | ``urlpatterns``. This should be a Python list, in the format returned by |
-
diff --git a/docs/topics/http/views.txt b/docs/topics/http/views.txt
|
a
|
b
|
|
| 50 | 50 | |
| 51 | 51 | .. admonition:: Django's Time Zone |
| 52 | 52 | |
| 53 | | Django includes a ``TIME_ZONE`` setting that defaults to |
| | 53 | Django includes a :setting:`TIME_ZONE` setting that defaults to |
| 54 | 54 | ``America/Chicago``. This probably isn't where you live, so you might want |
| 55 | 55 | to change it in your settings file. |
| 56 | 56 | |
| … |
… |
|
| 165 | 165 | in the 404. |
| 166 | 166 | |
| 167 | 167 | * The 404 view is passed a ``RequestContext`` and will have access to |
| 168 | | variables supplied by your ``TEMPLATE_CONTEXT_PROCESSORS`` setting (e.g., |
| 169 | | ``MEDIA_URL``). |
| | 168 | variables supplied by your :setting:`TEMPLATE_CONTEXT_PROCESSORS` setting (e.g., |
| | 169 | :setting:`MEDIA_URL`). |
| 170 | 170 | |
| 171 | | * If ``DEBUG`` is set to ``True`` (in your settings module), then your 404 |
| | 171 | * If :setting:`DEBUG` is set to ``True`` (in your settings module), then your 404 |
| 172 | 172 | view will never be used, and the traceback will be displayed instead. |
| 173 | 173 | |
| 174 | 174 | The 500 (server error) view |
-
diff --git a/docs/topics/i18n.txt b/docs/topics/i18n.txt
|
a
|
b
|
|
| 40 | 40 | optimizations so as not to load the internationalization machinery. |
| 41 | 41 | |
| 42 | 42 | You'll probably also want to remove ``'django.core.context_processors.i18n'`` |
| 43 | | from your ``TEMPLATE_CONTEXT_PROCESSORS`` setting. |
| | 43 | from your :setting:`TEMPLATE_CONTEXT_PROCESSORS` setting. |
| 44 | 44 | |
| 45 | 45 | If you do need internationalization: three steps |
| 46 | 46 | ================================================ |
| … |
… |
|
| 293 | 293 | |
| 294 | 294 | Each ``RequestContext`` has access to three translation-specific variables: |
| 295 | 295 | |
| 296 | | * ``LANGUAGES`` is a list of tuples in which the first element is the |
| | 296 | * :setting:`LANGUAGES` is a list of tuples in which the first element is the |
| 297 | 297 | language code and the second is the language name (translated into the |
| 298 | 298 | currently active locale). |
| 299 | 299 | |
| … |
… |
|
| 592 | 592 | selection based on data from the request. It customizes content for each user. |
| 593 | 593 | |
| 594 | 594 | To use ``LocaleMiddleware``, add ``'django.middleware.locale.LocaleMiddleware'`` |
| 595 | | to your ``MIDDLEWARE_CLASSES`` setting. Because middleware order matters, you |
| | 595 | to your :setting:`MIDDLEWARE_CLASSES` setting. Because middleware order matters, you |
| 596 | 596 | should follow these guidelines: |
| 597 | 597 | |
| 598 | 598 | * Make sure it's one of the first middlewares installed. |
| … |
… |
|
| 600 | 600 | makes use of session data. |
| 601 | 601 | * If you use ``CacheMiddleware``, put ``LocaleMiddleware`` after it. |
| 602 | 602 | |
| 603 | | For example, your ``MIDDLEWARE_CLASSES`` might look like this:: |
| | 603 | For example, your :setting:`MIDDLEWARE_CLASSES` might look like this:: |
| 604 | 604 | |
| 605 | 605 | MIDDLEWARE_CLASSES = ( |
| 606 | 606 | 'django.contrib.sessions.middleware.SessionMiddleware', |
| … |
… |
|
| 623 | 623 | |
| 624 | 624 | In Django version 0.96 and before, the cookie's name is hard-coded to |
| 625 | 625 | ``django_language``. In Django 1,0, The cookie name is set by the |
| 626 | | ``LANGUAGE_COOKIE_NAME`` setting. (The default name is |
| | 626 | :setting:`LANGUAGE_COOKIE_NAME` setting. (The default name is |
| 627 | 627 | ``django_language``.) |
| 628 | 628 | |
| 629 | 629 | * Failing that, it looks at the ``Accept-Language`` HTTP header. This |
| … |
… |
|
| 631 | 631 | prefer, in order by priority. Django tries each language in the header |
| 632 | 632 | until it finds one with available translations. |
| 633 | 633 | |
| 634 | | * Failing that, it uses the global ``LANGUAGE_CODE`` setting. |
| | 634 | * Failing that, it uses the global :setting:`LANGUAGE_CODE` setting. |
| 635 | 635 | |
| 636 | 636 | .. _locale-middleware-notes: |
| 637 | 637 | |
| … |
… |
|
| 649 | 649 | * Only languages listed in the :setting:`LANGUAGES` setting can be selected. |
| 650 | 650 | If you want to restrict the language selection to a subset of provided |
| 651 | 651 | languages (because your application doesn't provide all those languages), |
| 652 | | set ``LANGUAGES`` to a list of languages. For example:: |
| | 652 | set :setting:`LANGUAGES` to a list of languages. For example:: |
| 653 | 653 | |
| 654 | 654 | LANGUAGES = ( |
| 655 | 655 | ('de', _('German')), |
| … |
… |
|
| 662 | 662 | |
| 663 | 663 | .. _LANGUAGES setting: ../settings/#languages |
| 664 | 664 | |
| 665 | | * If you define a custom ``LANGUAGES`` setting, as explained in the |
| | 665 | * If you define a custom :setting:`LANGUAGES` setting, as explained in the |
| 666 | 666 | previous bullet, it's OK to mark the languages as translation strings |
| 667 | 667 | -- but use a "dummy" ``ugettext()`` function, not the one in |
| 668 | 668 | ``django.utils.translation``. You should *never* import |
| … |
… |
|
| 683 | 683 | With this arrangement, ``django-admin.py makemessages`` will still find |
| 684 | 684 | and mark these strings for translation, but the translation won't happen |
| 685 | 685 | at runtime -- so you'll have to remember to wrap the languages in the |
| 686 | | *real* ``ugettext()`` in any code that uses ``LANGUAGES`` at runtime. |
| | 686 | *real* ``ugettext()`` in any code that uses :setting:`LANGUAGES` at runtime. |
| 687 | 687 | |
| 688 | 688 | * The ``LocaleMiddleware`` can only select languages for which there is a |
| 689 | 689 | Django-provided base translation. If you want to provide translations |
| … |
… |
|
| 700 | 700 | Technical message IDs are easily recognized; they're all upper case. You |
| 701 | 701 | don't translate the message ID as with other messages, you provide the |
| 702 | 702 | correct local variant on the provided English value. For example, with |
| 703 | | ``DATETIME_FORMAT`` (or ``DATE_FORMAT`` or ``TIME_FORMAT``), this would |
| | 703 | :setting:`DATETIME_FORMAT` (or :setting:`DATE_FORMAT` or :setting:`TIME_FORMAT`), this would |
| 704 | 704 | be the format string that you want to use in your language. The format |
| 705 | 705 | is identical to the format strings used by the ``now`` template tag. |
| 706 | 706 | |
| … |
… |
|
| 757 | 757 | |
| 758 | 758 | * ``$APPPATH/locale/<language>/LC_MESSAGES/django.(po|mo)`` |
| 759 | 759 | * ``$PROJECTPATH/locale/<language>/LC_MESSAGES/django.(po|mo)`` |
| 760 | | * All paths listed in ``LOCALE_PATHS`` in your settings file are |
| | 760 | * All paths listed in :setting:`LOCALE_PATHS` in your settings file are |
| 761 | 761 | searched in that order for ``<language>/LC_MESSAGES/django.(po|mo)`` |
| 762 | 762 | * ``$PYTHONPATH/django/conf/locale/<language>/LC_MESSAGES/django.(po|mo)`` |
| 763 | 763 | |
| … |
… |
|
| 769 | 769 | to produce the binary ``django.mo`` files that are used by ``gettext``. |
| 770 | 770 | |
| 771 | 771 | You can also run ``django-admin.py compilemessages --settings=path.to.settings`` |
| 772 | | to make the compiler process all the directories in your ``LOCALE_PATHS`` |
| | 772 | to make the compiler process all the directories in your :setting:`LOCALE_PATHS` |
| 773 | 773 | setting. |
| 774 | 774 | |
| 775 | 775 | Application message files are a bit complicated to discover -- they need the |
| … |
… |
|
| 806 | 806 | parameter set in request. If session support is enabled, the view |
| 807 | 807 | saves the language choice in the user's session. Otherwise, it saves the |
| 808 | 808 | language choice in a cookie that is by default named ``django_language``. |
| 809 | | (The name can be changed through the ``LANGUAGE_COOKIE_NAME`` setting if you're |
| | 809 | (The name can be changed through the :setting:`LANGUAGE_COOKIE_NAME` setting if you're |
| 810 | 810 | using the Django development version.) |
| 811 | 811 | |
| 812 | 812 | After setting the language choice, Django redirects the user, following this |
| … |
… |
|
| 869 | 869 | ) |
| 870 | 870 | |
| 871 | 871 | Each string in ``packages`` should be in Python dotted-package syntax (the |
| 872 | | same format as the strings in ``INSTALLED_APPS``) and should refer to a package |
| | 872 | same format as the strings in :setting:`INSTALLED_APPS`) and should refer to a package |
| 873 | 873 | that contains a ``locale`` directory. If you specify multiple packages, all |
| 874 | 874 | those catalogs are merged into one catalog. This is useful if you have |
| 875 | 875 | JavaScript that uses strings from different applications. |
| … |
… |
|
| 884 | 884 | signs in the URL. This is especially useful if your pages use code from |
| 885 | 885 | different apps and this changes often and you don't want to pull in one big |
| 886 | 886 | catalog file. As a security measure, these values can only be either |
| 887 | | ``django.conf`` or any package from the ``INSTALLED_APPS`` setting. |
| | 887 | ``django.conf`` or any package from the :setting:`INSTALLED_APPS` setting. |
| 888 | 888 | |
| 889 | 889 | Using the JavaScript translation catalog |
| 890 | 890 | ---------------------------------------- |
-
diff --git a/docs/topics/templates.txt b/docs/topics/templates.txt
|
a
|
b
|
|
| 99 | 99 | ``title`` attribute of the ``section`` object. |
| 100 | 100 | |
| 101 | 101 | If you use a variable that doesn't exist, the template system will insert |
| 102 | | the value of the ``TEMPLATE_STRING_IF_INVALID`` setting, which is set to ``''`` |
| | 102 | the value of the :setting:`TEMPLATE_STRING_IF_INVALID` setting, which is set to ``''`` |
| 103 | 103 | (the empty string) by default. |
| 104 | 104 | |
| 105 | 105 | See `Using the built-in reference`_, below, for help on finding what variables |
-
diff --git a/docs/topics/testing.txt b/docs/topics/testing.txt
|
a
|
b
|
|
| 879 | 879 | ``django.test.TestCase`` provides the ability to customize the URLconf |
| 880 | 880 | configuration for the duration of the execution of a test suite. If your |
| 881 | 881 | ``TestCase`` instance defines an ``urls`` attribute, the ``TestCase`` will use |
| 882 | | the value of that attribute as the ``ROOT_URLCONF`` for the duration of that |
| | 882 | the value of that attribute as the :setting:`ROOT_URLCONF` for the duration of that |
| 883 | 883 | test. |
| 884 | 884 | |
| 885 | 885 | For example:: |