diff options
| author | Nick Pope <nick.pope@flightdataservices.com> | 2020-04-30 11:12:05 +0100 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2020-05-13 09:38:59 +0200 |
| commit | 4eb5e4ee4fe097986df839b11efb69b6bb9db00f (patch) | |
| tree | 4a164e7ac55d6e59fb15109b497d9402e0ca7cfe /docs/topics | |
| parent | 345fa40cb5459fab8ce06744396ab5ceaf2d04ee (diff) | |
[3.1.x] Used :envvar: role and .. envvar:: directive in various docs.
Backport of fbdb032de266ba5f82e061ab204f6c622889d563 from master
Diffstat (limited to 'docs/topics')
| -rw-r--r-- | docs/topics/async.txt | 4 | ||||
| -rw-r--r-- | docs/topics/settings.txt | 34 |
2 files changed, 20 insertions, 18 deletions
diff --git a/docs/topics/async.txt b/docs/topics/async.txt index 99b7f06113..09a4775966 100644 --- a/docs/topics/async.txt +++ b/docs/topics/async.txt @@ -120,6 +120,8 @@ mode if you have asynchronous code in your project. Async safety ============ +.. envvar:: DJANGO_ALLOW_ASYNC_UNSAFE + Certain key parts of Django are not able to operate safely in an async environment, as they have global state that is not coroutine-aware. These parts of Django are classified as "async-unsafe", and are protected from execution in @@ -146,7 +148,7 @@ if the requirement is forced on you by an external environment, such as in a Jupyter_ notebook. If you are sure there is no chance of the code being run concurrently, and you *absolutely* need to run this sync code from an async context, then you can disable the warning by setting the -``DJANGO_ALLOW_ASYNC_UNSAFE`` environment variable to any value. +:envvar:`DJANGO_ALLOW_ASYNC_UNSAFE` environment variable to any value. .. warning:: diff --git a/docs/topics/settings.txt b/docs/topics/settings.txt index 7a420b6777..d09ba08b10 100644 --- a/docs/topics/settings.txt +++ b/docs/topics/settings.txt @@ -40,10 +40,10 @@ Designating the settings .. envvar:: DJANGO_SETTINGS_MODULE When you use Django, you have to tell it which settings you're using. Do this -by using an environment variable, ``DJANGO_SETTINGS_MODULE``. +by using an environment variable, :envvar:`DJANGO_SETTINGS_MODULE`. -The value of ``DJANGO_SETTINGS_MODULE`` should be in Python path syntax, e.g. -``mysite.settings``. Note that the settings module should be on the +The value of :envvar:`DJANGO_SETTINGS_MODULE` should be in Python path syntax, +e.g. ``mysite.settings``. Note that the settings module should be on the Python `import search path`_. .. _import search path: https://www.diveinto.org/python3/your-first-python-program.html#importsearchpath @@ -170,10 +170,10 @@ a convention. .. _settings-without-django-settings-module: -Using settings without setting ``DJANGO_SETTINGS_MODULE`` -========================================================= +Using settings without setting :envvar:`DJANGO_SETTINGS_MODULE` +=============================================================== -In some cases, you might want to bypass the ``DJANGO_SETTINGS_MODULE`` +In some cases, you might want to bypass the :envvar:`DJANGO_SETTINGS_MODULE` environment variable. For example, if you're using the template system by itself, you likely don't want to have to set up an environment variable pointing to a settings module. @@ -234,19 +234,19 @@ defaults, so you must specify a value for every possible setting that might be used in that code you are importing. Check in ``django.conf.settings.global_settings`` for the full list. -Either ``configure()`` or ``DJANGO_SETTINGS_MODULE`` is required ----------------------------------------------------------------- +Either ``configure()`` or :envvar:`DJANGO_SETTINGS_MODULE` is required +---------------------------------------------------------------------- -If you're not setting the ``DJANGO_SETTINGS_MODULE`` environment variable, you -*must* call ``configure()`` at some point before using any code that reads -settings. +If you're not setting the :envvar:`DJANGO_SETTINGS_MODULE` environment +variable, you *must* call ``configure()`` at some point before using any code +that reads settings. -If you don't set ``DJANGO_SETTINGS_MODULE`` and don't call ``configure()``, -Django will raise an ``ImportError`` exception the first time a setting -is accessed. +If you don't set :envvar:`DJANGO_SETTINGS_MODULE` and don't call +``configure()``, Django will raise an ``ImportError`` exception the first time +a setting is accessed. -If you set ``DJANGO_SETTINGS_MODULE``, access settings values somehow, *then* -call ``configure()``, Django will raise a ``RuntimeError`` indicating +If you set :envvar:`DJANGO_SETTINGS_MODULE`, access settings values somehow, +*then* call ``configure()``, Django will raise a ``RuntimeError`` indicating that settings have already been configured. There is a property for this purpose: @@ -262,7 +262,7 @@ Also, it's an error to call ``configure()`` more than once, or to call ``configure()`` after any setting has been accessed. It boils down to this: Use exactly one of either ``configure()`` or -``DJANGO_SETTINGS_MODULE``. Not both, and not neither. +:envvar:`DJANGO_SETTINGS_MODULE`. Not both, and not neither. Calling ``django.setup()`` is required for "standalone" Django usage -------------------------------------------------------------------- |
