File: README.rst

package info (click to toggle)
python-django-split-settings 0.3.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 364 kB
  • sloc: python: 368; makefile: 23
file content (95 lines) | stat: -rw-r--r-- 2,434 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95

.. image:: logo-black.png
     :target: https://github.com/sobolevn/django-split-settings
     :align: center

----------

Organize Django settings into multiple files and directories. Easily
override and modify settings. Use wildcards in settings file paths
and mark settings files as optional.

Read this `medium`_ post for more information.

.. _medium: https://medium.com/wemake-services/managing-djangos-settings-e2b7f496120d

Requirements
------------

While this package will most likely work with the most versions of ``django``, we do not officially support any versions except the latest release and the current LTS version, which are ``1.11`` and ``2.0`` right now.

This package has no dependencies itself.


Installation
------------

Install by using ``pip``:

.. code:: bash

    pip install django-split-settings

We also recommend to try `pipenv <https://docs.pipenv.org/>`_ to handle dependencies.


Usage
-----

Replace your existing ``settings.py`` with a list of components that
make up your Django settings. Preferably create a settings package
that contains all the files.

Here's a minimal example:

.. code:: python

    from split_settings.tools import optional, include

    include(
        'components/base.py',
        'components/database.py',
        optional('local_settings.py')
    )

In the example, the files ``base.py`` and ``database.py`` are included
in that order from the subdirectory called ``components/``.
``local_settings.py`` in the same directory is included if it exists.

**Note:** The local context is passed on to each file, so each
following file can access and modify the settings declared in the
previous files.

We also made a in-depth `tutorial`_.

.. _tutorial: https://medium.com/wemake-services/managing-djangos-settings-e2b7f496120d


Tips and tricks
---------------

You can use wildcards in file paths:

.. code:: python

    include('components/my_app/*.py')

Note that files are included in the order that ``glob`` returns them,
probably in the same order as what ``ls -U`` would list them. The
files are NOT in alphabetical order.


Do you want to contribute?
--------------------------

Read the `contributing`_ file.

.. _contributing: https://github.com/sobolevn/django-split-settings/blob/master/CONTRIBUTING.rst


Version history
---------------

See `changelog`_ file.

.. _changelog: https://github.com/sobolevn/django-split-settings/blob/master/CHANGELOG.rst