{"id":13415584,"url":"https://github.com/joke2k/django-environ","last_synced_at":"2026-02-14T03:30:09.053Z","repository":{"id":7800925,"uuid":"9171234","full_name":"joke2k/django-environ","owner":"joke2k","description":"Django-environ allows you to utilize 12factor inspired environment variables to configure your Django application.","archived":false,"fork":false,"pushed_at":"2025-04-28T18:01:52.000Z","size":824,"stargazers_count":3078,"open_issues_count":83,"forks_count":322,"subscribers_count":36,"default_branch":"main","last_synced_at":"2025-05-05T23:07:45.428Z","etag":null,"topics":["django","hacktoberfest","python","settings","twelve-factor"],"latest_commit_sha":null,"homepage":"https://django-environ.rtfd.org","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/joke2k.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGELOG.rst","contributing":"CONTRIBUTING.rst","funding":".github/FUNDING.yml","license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.rst","support":null,"governance":null,"roadmap":null,"authors":"AUTHORS.rst","dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"joke2k","patreon":null,"open_collective":"joke2k","ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2013-04-02T13:50:07.000Z","updated_at":"2025-05-02T13:15:24.000Z","dependencies_parsed_at":"2023-01-14T11:42:32.390Z","dependency_job_id":"ce2dcda5-1ed8-4d88-8cff-c420a36bfcf9","html_url":"https://github.com/joke2k/django-environ","commit_stats":{"total_commits":494,"total_committers":98,"mean_commits":5.040816326530612,"dds":0.5607287449392713,"last_synced_commit":"df301b607f287df049b4efeda14717fcdbe123b1"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joke2k%2Fdjango-environ","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joke2k%2Fdjango-environ/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joke2k%2Fdjango-environ/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joke2k%2Fdjango-environ/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joke2k","download_url":"https://codeload.github.com/joke2k/django-environ/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252590609,"owners_count":21772937,"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":["django","hacktoberfest","python","settings","twelve-factor"],"created_at":"2024-07-30T21:00:50.508Z","updated_at":"2026-02-14T03:30:09.016Z","avatar_url":"https://github.com/joke2k.png","language":"Python","funding_links":["https://github.com/sponsors/joke2k","https://opencollective.com/joke2k","https://opencollective.com/django-environ"],"categories":["Third-Party Packages","Python","Settings","Django Utilities","Database and ORM","设置","Django"],"sub_categories":["Configuration","Podcasts","Environment"],"readme":".. raw:: html\n\n    \u003ch1 align=\"center\"\u003edjango-environ\u003c/h1\u003e\n    \u003cp align=\"center\"\u003e\n        \u003ca href=\"https://pypi.python.org/pypi/django-environ\"\u003e\n            \u003cimg src=\"https://img.shields.io/pypi/v/django-environ.svg\" alt=\"Latest version released on PyPi\" /\u003e\n        \u003c/a\u003e\n        \u003ca href=\"https://coveralls.io/github/joke2k/django-environ\"\u003e\n            \u003cimg src=\"https://coveralls.io/repos/github/joke2k/django-environ/badge.svg\" alt=\"Coverage Status\" /\u003e\n        \u003c/a\u003e\n        \u003ca href=\"https://github.com/joke2k/django-environ/actions?workflow=CI\"\u003e\n            \u003cimg src=\"https://github.com/joke2k/django-environ/workflows/CI/badge.svg?branch=develop\" alt=\"CI Status\" /\u003e\n        \u003c/a\u003e\n        \u003ca href=\"https://opencollective.com/django-environ\"\u003e\n            \u003cimg src=\"https://opencollective.com/django-environ/sponsors/badge.svg\" alt=\"Sponsors on Open Collective\" /\u003e\n        \u003c/a\u003e\n        \u003ca href=\"https://opencollective.com/django-environ\"\u003e\n            \u003cimg src=\"https://opencollective.com/django-environ/backers/badge.svg\" alt=\"Backers on Open Collective\" /\u003e\n        \u003c/a\u003e\n        \u003ca href=\"https://saythanks.io/to/joke2k\"\u003e\n            \u003cimg src=\"https://img.shields.io/badge/Say%20Thanks-!-1EAEDB.svg\" alt=\"Say Thanks!\" /\u003e\n        \u003c/a\u003e\n        \u003ca href=\"https://raw.githubusercontent.com/joke2k/django-environ/main/LICENSE.txt\"\u003e\n            \u003cimg src=\"https://img.shields.io/badge/license-MIT-blue.svg\" alt=\"Package license\" /\u003e\n        \u003c/a\u003e\n    \u003c/p\u003e\n\n.. -teaser-begin-\n\n``django-environ`` is the Python package that allows you to use\n`Twelve-factor methodology \u003chttps://www.12factor.net/\u003e`_ to configure your\nDjango application with environment variables.\n\n.. -teaser-end-\n\nFor that, it gives you an easy way to configure Django application using\nenvironment variables obtained from an environment file and provided by the OS:\n\n.. -code-begin-\n\n.. code-block:: python\n\n   import environ\n   import os\n\n   env = environ.Env(\n       # set casting, default value\n       DEBUG=(bool, False)\n   )\n\n   # Set the project base directory\n   BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))\n\n   # Take environment variables from .env file\n   environ.Env.read_env(os.path.join(BASE_DIR, '.env'))\n\n   # False if not in os.environ because of casting above\n   DEBUG = env('DEBUG')\n\n   # Raises Django's ImproperlyConfigured\n   # exception if SECRET_KEY not in os.environ\n   SECRET_KEY = env('SECRET_KEY')\n\n   # Parse database connection url strings\n   # like psql://user:pass@127.0.0.1:8458/db\n   DATABASES = {\n       # read os.environ['DATABASE_URL'] and raises\n       # ImproperlyConfigured exception if not found\n       #\n       # The db() method is an alias for db_url().\n       'default': env.db(),\n\n       # read os.environ['SQLITE_URL']\n       'extra': env.db_url(\n           'SQLITE_URL',\n           default='sqlite:////tmp/my-tmp-sqlite.db'\n       )\n   }\n\n   CACHES = {\n       # Read os.environ['CACHE_URL'] and raises\n       # ImproperlyConfigured exception if not found.\n       #\n       # The cache() method is an alias for cache_url().\n       'default': env.cache(),\n\n       # read os.environ['REDIS_URL']\n       'redis': env.cache_url('REDIS_URL')\n   }\n\n.. -overview-\n\nThe idea of this package is to unify a lot of packages that make the same stuff:\nTake a string from ``os.environ``, parse and cast it to some of useful python\ntyped variables. To do that and to use the `12factor \u003chttps://www.12factor.net/\u003e`_\napproach, some connection strings are expressed as url, so this package can parse\nit and return a ``urllib.parse.ParseResult``. These strings from ``os.environ``\nare loaded from a ``.env`` file and filled in ``os.environ`` with ``setdefault``\nmethod, to avoid to overwrite the real environ.\nA similar approach is used in\n`Two Scoops of Django \u003chttps://web.archive.org/web/20240121133956/https://www.feldroy.com/books/two-scoops-of-django-3-x\u003e`_\nbook and explained in `12factor-django \u003chttps://wellfire.co/learn/easier-12-factor-django\u003e`_\narticle.\n\n\nUsing ``django-environ`` you can stop to make a lot of unversioned\n``settings_*.py`` to configure your app.\nSee `cookiecutter-django \u003chttps://github.com/cookiecutter/cookiecutter-django\u003e`_\nfor a concrete example on using with a django project.\n\n**Feature Support**\n\n- Fast and easy multi environment for deploy\n- Fill ``os.environ`` with .env file variables\n- Variables casting\n- Url variables exploded to django specific package settings\n- Optional support for Docker-style file based config variables (use\n  ``environ.FileAwareEnv`` instead of ``environ.Env``)\n\n.. -project-information-\n\nProject Information\n===================\n\n``django-environ`` is released under the `MIT / X11 License \u003chttps://choosealicense.com/licenses/mit/\u003e`__,\nits documentation lives at `Read the Docs \u003chttps://django-environ.readthedocs.io/en/latest/\u003e`_,\nthe code on `GitHub \u003chttps://github.com/joke2k/django-environ\u003e`_,\nand the latest release on `PyPI \u003chttps://pypi.org/project/django-environ/\u003e`_.\n\nIt’s rigorously tested on Python 3.9+, and officially supports\nDjango 2.2, 3.0, 3.1, 3.2, 4.0, 4.1, 4.2, 5.0, and 5.1.\n\nIf you'd like to contribute to ``django-environ`` you're most welcome!\n\n.. -support-\n\nSupport\n=======\n\nShould you have any question, any remark, or if you find a bug, or if there is\nsomething you can't do with the ``django-environ``, please\n`open an issue \u003chttps://github.com/joke2k/django-environ\u003e`_.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoke2k%2Fdjango-environ","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoke2k%2Fdjango-environ","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoke2k%2Fdjango-environ/lists"}