{"id":13415603,"url":"https://github.com/jazzband/django-configurations","last_synced_at":"2025-05-13T19:11:34.244Z","repository":{"id":4033254,"uuid":"5133993","full_name":"jazzband/django-configurations","owner":"jazzband","description":"A helper for organizing Django project settings by relying on well established programming patterns.","archived":false,"fork":false,"pushed_at":"2024-11-18T23:53:14.000Z","size":585,"stargazers_count":1123,"open_issues_count":59,"forks_count":148,"subscribers_count":21,"default_branch":"master","last_synced_at":"2025-05-05T12:02:22.277Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://django-configurations.readthedocs.io/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jazzband.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS","dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"custom":["https://jazzband.co/donate"]}},"created_at":"2012-07-21T13:56:20.000Z","updated_at":"2025-05-01T23:15:29.000Z","dependencies_parsed_at":"2023-07-05T21:01:45.890Z","dependency_job_id":"60f3220e-a39e-49c6-8134-ad0133f2e102","html_url":"https://github.com/jazzband/django-configurations","commit_stats":{"total_commits":382,"total_committers":67,"mean_commits":5.701492537313433,"dds":0.5,"last_synced_commit":"cad6dcb7f00c26702e5c5305901712409b94c848"},"previous_names":[],"tags_count":24,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jazzband%2Fdjango-configurations","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jazzband%2Fdjango-configurations/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jazzband%2Fdjango-configurations/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jazzband%2Fdjango-configurations/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jazzband","download_url":"https://codeload.github.com/jazzband/django-configurations/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253621771,"owners_count":21937576,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-30T21:00:50.660Z","updated_at":"2025-05-13T19:11:34.204Z","avatar_url":"https://github.com/jazzband.png","language":"Python","funding_links":["https://jazzband.co/donate"],"categories":["Third-Party Packages","Settings","Python","Django Utilities","设置"],"sub_categories":["Configuration"],"readme":"django-configurations |latest-version|\n======================================\n\n|jazzband| |build-status| |codecov| |docs| |python-support| |django-support|\n\ndjango-configurations eases Django project configuration by relying\non the composability of Python classes. It extends the notion of\nDjango's module based settings loading with well established\nobject oriented programming patterns.\n\nCheck out the `documentation`_ for more complete examples.\n\n.. |latest-version| image:: https://img.shields.io/pypi/v/django-configurations.svg\n   :target: https://pypi.python.org/pypi/django-configurations\n   :alt: Latest version on PyPI\n\n.. |jazzband| image:: https://jazzband.co/static/img/badge.svg\n   :target: https://jazzband.co/\n   :alt: Jazzband\n\n.. |build-status| image:: https://github.com/jazzband/django-configurations/workflows/Test/badge.svg\n   :target: https://github.com/jazzband/django-configurations/actions\n   :alt: Build Status\n\n.. |codecov| image:: https://codecov.io/github/jazzband/django-configurations/coverage.svg?branch=master\n   :target: https://codecov.io/github/jazzband/django-configurations?branch=master\n   :alt: Test coverage status\n\n.. |docs| image:: https://img.shields.io/readthedocs/django-configurations/latest.svg\n   :target: https://readthedocs.org/projects/django-configurations/\n   :alt: Documentation status\n\n.. |python-support| image:: https://img.shields.io/pypi/pyversions/django-configurations.svg\n   :target: https://pypi.python.org/pypi/django-configurations\n   :alt: Supported Python versions\n\n.. |django-support| image:: https://img.shields.io/pypi/djversions/django-configurations\n   :target: https://pypi.org/project/django-configurations\n   :alt: Supported Django versions\n\n.. _documentation: https://django-configurations.readthedocs.io/en/latest/\n\nQuickstart\n----------\n\nInstall django-configurations:\n\n.. code-block:: console\n\n    $ python -m pip install django-configurations\n\nor, alternatively, if you want to use URL-based values:\n\n.. code-block:: console\n\n    $ python -m pip install django-configurations[cache,database,email,search]\n\nThen subclass the included ``configurations.Configuration`` class in your\nproject's **settings.py** or any other module you're using to store the\nsettings constants, e.g.:\n\n.. code-block:: python\n\n    # mysite/settings.py\n\n    from configurations import Configuration\n\n    class Dev(Configuration):\n        DEBUG = True\n\nSet the ``DJANGO_CONFIGURATION`` environment variable to the name of the class\nyou just created, e.g. in bash:\n\n.. code-block:: console\n\n    $ export DJANGO_CONFIGURATION=Dev\n\nand the ``DJANGO_SETTINGS_MODULE`` environment variable to the module\nimport path as usual, e.g. in bash:\n\n.. code-block:: console\n\n    $ export DJANGO_SETTINGS_MODULE=mysite.settings\n\n*Alternatively* supply the ``--configuration`` option when using Django\nmanagement commands along the lines of Django's default ``--settings``\ncommand line option, e.g.\n\n.. code-block:: console\n\n    $ python -m manage runserver --settings=mysite.settings --configuration=Dev\n\nTo enable Django to use your configuration you now have to modify your\n**manage.py**, **wsgi.py** or **asgi.py** script to use django-configurations's versions\nof the appropriate starter functions, e.g. a typical **manage.py** using\ndjango-configurations would look like this:\n\n.. code-block:: python\n\n    #!/usr/bin/env python\n\n    import os\n    import sys\n\n    if __name__ == \"__main__\":\n        os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mysite.settings')\n        os.environ.setdefault('DJANGO_CONFIGURATION', 'Dev')\n\n        from configurations.management import execute_from_command_line\n\n        execute_from_command_line(sys.argv)\n\nNotice in line 10 we don't use the common tool\n``django.core.management.execute_from_command_line`` but instead\n``configurations.management.execute_from_command_line``.\n\nThe same applies to your **wsgi.py** file, e.g.:\n\n.. code-block:: python\n\n    import os\n\n    os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mysite.settings')\n    os.environ.setdefault('DJANGO_CONFIGURATION', 'Dev')\n\n    from configurations.wsgi import get_wsgi_application\n\n    application = get_wsgi_application()\n\nHere we don't use the default ``django.core.wsgi.get_wsgi_application``\nfunction but instead ``configurations.wsgi.get_wsgi_application``.\n\nOr if you are not serving your app via WSGI but ASGI instead, you need to modify your **asgi.py** file too.:\n\n.. code-block:: python\n\n    import os\n\n    os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mysite.settings')\n    os.environ.setdefault('DJANGO_CONFIGURATION', 'Dev')\n\n    from configurations.asgi import get_asgi_application\n\n    application = get_asgi_application()\n\nThat's it! You can now use your project with ``manage.py`` and your favorite\nWSGI/ASGI enabled server.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjazzband%2Fdjango-configurations","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjazzband%2Fdjango-configurations","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjazzband%2Fdjango-configurations/lists"}