Skip to content

Commit

Permalink
Fix jazzband#353 Improve code blocks in documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
pauloxnet committed Feb 15, 2023
1 parent a1f072e commit adaf920
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 22 deletions.
10 changes: 5 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -73,22 +73,22 @@ 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``
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
Expand Down
8 changes: 3 additions & 5 deletions docs/cookbook.rst
Original file line number Diff line number Diff line change
Expand Up @@ -74,18 +74,16 @@ Example:

.. code-block:: console
$ tree mysite_env/
$ tree --noreport mysite_env/
mysite_env/
├── DJANGO_SETTINGS_MODULE
├── DJANGO_DEBUG
├── DJANGO_DATABASE_URL
├── 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.:
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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!
8 changes: 4 additions & 4 deletions docs/patterns.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,17 @@ 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``
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
-----------------
Expand Down
22 changes: 15 additions & 7 deletions docs/values.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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'``.
Expand Down Expand Up @@ -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'>
Expand Down Expand Up @@ -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(['[email protected]'], separator=';')
And override it::
And override it:
.. code-block:: console
DJANGO_EMERGENCY_EMAILS="[email protected];[email protected];[email protected]" gunicorn mysite.wsgi:application
$ DJANGO_EMERGENCY_EMAILS="[email protected];[email protected];[email protected]" gunicorn mysite.wsgi:application
.. class:: TupleValue

Expand Down

0 comments on commit adaf920

Please sign in to comment.