Fix #353 Improve code blocks in documentation

This commit is contained in:
Paolo Melchiorre 2023-02-14 16:55:26 +01:00
parent a1f072ebf3
commit adaf92085f
5 changed files with 28 additions and 22 deletions

View file

@ -47,13 +47,13 @@ Install django-configurations:
.. code-block:: console
pip install django-configurations
$ python -m pip install django-configurations
or, alternatively, if you want to use URL-based values:
.. code-block:: console
pip install django-configurations[cache,database,email,search]
$ python -m pip install django-configurations[cache,database,email,search]
Then subclass the included ``configurations.Configuration`` class in your
project's **settings.py** or any other module you're using to store the
@ -73,14 +73,14 @@ you just created, e.g. in bash:
.. code-block:: console
export DJANGO_CONFIGURATION=Dev
$ export DJANGO_CONFIGURATION=Dev
and the ``DJANGO_SETTINGS_MODULE`` environment variable to the module
import path as usual, e.g. in bash:
.. code-block:: console
export DJANGO_SETTINGS_MODULE=mysite.settings
$ export DJANGO_SETTINGS_MODULE=mysite.settings
*Alternatively* supply the ``--configuration`` option when using Django
management commands along the lines of Django's default ``--settings``
@ -88,7 +88,7 @@ command line option, e.g.
.. code-block:: console
python manage.py runserver --settings=mysite.settings --configuration=Dev
$ python -m manage runserver --settings=mysite.settings --configuration=Dev
To enable Django to use your configuration you now have to modify your
**manage.py**, **wsgi.py** or **asgi.py** script to use django-configurations's versions

View file

@ -74,7 +74,7 @@ Example:
.. code-block:: console
$ tree mysite_env/
$ tree --noreport mysite_env/
mysite_env/
├── DJANGO_SETTINGS_MODULE
├── DJANGO_DEBUG
@ -82,10 +82,8 @@ Example:
├── DJANGO_CACHE_URL
└── PYTHONSTARTUP
0 directories, 3 files
$ cat mysite_env/DJANGO_CACHE_URL
redis://user@host:port/1
$
Then, to enable the ``mysite_env`` environment variables, simply use the
``envdir`` command line tool as a prefix for your program, e.g.:
@ -151,13 +149,13 @@ First install Django 1.8.x and django-configurations:
.. code-block:: console
$ pip install -r https://raw.github.com/jazzband/django-configurations/templates/1.8.x/requirements.txt
$ python -m pip install -r https://raw.github.com/jazzband/django-configurations/templates/1.8.x/requirements.txt
Or Django 1.8:
.. code-block:: console
$ django-admin.py startproject mysite -v2 --template https://github.com/jazzband/django-configurations/archive/templates/1.8.x.zip
$ python -m django startproject mysite -v2 --template https://github.com/jazzband/django-configurations/archive/templates/1.8.x.zip
Now you have a default Django 1.8.x project in the ``mysite``
directory that uses django-configurations.

View file

@ -93,6 +93,6 @@ Bugs and feature requests
As always your mileage may vary, so please don't hesitate to send feature
requests and bug reports:
https://github.com/jazzband/django-configurations/issues
- https://github.com/jazzband/django-configurations/issues
Thanks!

View file

@ -31,9 +31,9 @@ it should be ``Prod``. In Bash that would be:
.. code-block:: console
export DJANGO_SETTINGS_MODULE=mysite.settings
export DJANGO_CONFIGURATION=Prod
python manage.py runserver
$ export DJANGO_SETTINGS_MODULE=mysite.settings
$ export DJANGO_CONFIGURATION=Prod
$ python -m manage runserver
Alternatively you can use the ``--configuration`` option when using Django
management commands along the lines of Django's default ``--settings``
@ -41,7 +41,7 @@ command line option, e.g.
.. code-block:: console
python manage.py runserver --settings=mysite.settings --configuration=Prod
$ python -m manage runserver --settings=mysite.settings --configuration=Prod
Property settings
-----------------

View file

@ -86,9 +86,11 @@ prefixed with ``DJANGO_``. E.g.:
django-configurations will try to read the ``DJANGO_ROOT_URLCONF`` environment
variable when deciding which value the ``ROOT_URLCONF`` setting should have.
When you run the web server simply specify that environment variable
(e.g. in your init script)::
(e.g. in your init script):
DJANGO_ROOT_URLCONF=mysite.debugging_urls gunicorn mysite.wsgi:application
.. code-block:: console
$ DJANGO_ROOT_URLCONF=mysite.debugging_urls gunicorn mysite.wsgi:application
If the environment variable can't be found it'll use the default
``'mysite.urls'``.
@ -125,7 +127,9 @@ Allow final value to be used outside the configuration context
You may use the ``environ_name`` parameter to allow a :class:`~Value` to be
directly converted to its final value for use outside of the configuration
context::
context:
.. code-block:: pycon
>>> type(values.Value([]))
<class 'configurations.values.Value'>
@ -283,17 +287,21 @@ Type values
MONTY_PYTHONS = ListValue(['John Cleese', 'Eric Idle'],
converter=check_monty_python)
You can override this list with an environment variable like this::
You can override this list with an environment variable like this:
DJANGO_MONTY_PYTHONS="Terry Jones,Graham Chapman" gunicorn mysite.wsgi:application
.. code-block:: console
$ DJANGO_MONTY_PYTHONS="Terry Jones,Graham Chapman" gunicorn mysite.wsgi:application
Use a custom separator::
EMERGENCY_EMAILS = ListValue(['admin@mysite.net'], separator=';')
And override it::
And override it:
DJANGO_EMERGENCY_EMAILS="admin@mysite.net;manager@mysite.org;support@mysite.com" gunicorn mysite.wsgi:application
.. code-block:: console
$ DJANGO_EMERGENCY_EMAILS="admin@mysite.net;manager@mysite.org;support@mysite.com" gunicorn mysite.wsgi:application
.. class:: TupleValue