{"id":13814338,"url":"https://github.com/jpadilla/django-dotenv","last_synced_at":"2025-05-15T18:05:44.483Z","repository":{"id":8936792,"uuid":"10669347","full_name":"jpadilla/django-dotenv","owner":"jpadilla","description":"Loads environment variables from .env","archived":false,"fork":false,"pushed_at":"2021-11-29T15:55:42.000Z","size":29,"stargazers_count":571,"open_issues_count":17,"forks_count":42,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-03-31T22:17:59.909Z","etag":null,"topics":["django","dotenv","python"],"latest_commit_sha":null,"homepage":"","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/jpadilla.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-06-13T15:32:20.000Z","updated_at":"2025-03-12T10:20:36.000Z","dependencies_parsed_at":"2022-08-07T05:00:19.798Z","dependency_job_id":null,"html_url":"https://github.com/jpadilla/django-dotenv","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpadilla%2Fdjango-dotenv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpadilla%2Fdjango-dotenv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpadilla%2Fdjango-dotenv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpadilla%2Fdjango-dotenv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jpadilla","download_url":"https://codeload.github.com/jpadilla/django-dotenv/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247744332,"owners_count":20988783,"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","dotenv","python"],"created_at":"2024-08-04T04:01:54.211Z","updated_at":"2025-04-07T23:08:02.413Z","avatar_url":"https://github.com/jpadilla.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"django-dotenv\n=============\n\n|build-status-image| |pypi-version|\n\n`foreman \u003chttps://github.com/ddollar/foreman\u003e`__ reads from ``.env``.\n``manage.py`` doesn't. Let's fix that.\n\nOriginal implementation was written by\n`@jacobian \u003chttps://github.com/jacobian\u003e`__.\n\nTested on Python 3.5, 3.6, 3.7 and 3.8.\n\nInstallation\n------------\n\n::\n\n    pip install django-dotenv\n\nUsage\n-----\n\nYour ``manage.py`` should look like:\n\n.. code:: python\n\n    #!/usr/bin/env python\n    import os\n    import sys\n\n    import dotenv\n\n\n    if __name__ == \"__main__\":\n        dotenv.read_dotenv()\n\n        os.environ.setdefault(\"DJANGO_SETTINGS_MODULE\", \"project.settings\")\n        try:\n            from django.core.management import execute_from_command_line\n        except ImportError as exc:\n            raise ImportError(\n                \"Couldn't import Django. Are you sure it's installed and \"\n                \"available on your PYTHONPATH environment variable? Did you \"\n                \"forget to activate a virtual environment?\"\n            ) from exc\n        execute_from_command_line(sys.argv)\n\nYou can also pass ``read_dotenv()`` an explicit path to the ``.env``\nfile, or to the directory where it lives. It's smart, it'll figure it\nout.\n\nBy default, variables that are already defined in the environment take\nprecedence over those in your ``.env`` file.  To change this, call\n``read_dotenv(override=True)``.\n\nCheck out\n`tests.py \u003chttps://github.com/jpadilla/django-dotenv/blob/master/tests.py\u003e`__\nto see all the supported formats that your ``.env`` can have.\n\nUsing with WSGI\n~~~~~~~~~~~~~~~\n\nIf you're running Django with WSGI and want to load a ``.env`` file,\nyour ``wsgi.py`` would look like this:\n\n.. code:: python\n\n    import os\n\n    import dotenv\n    from django.core.wsgi import get_wsgi_application\n\n    dotenv.read_dotenv(os.path.join(os.path.dirname(os.path.dirname(__file__)), '.env'))\n\n    os.environ.setdefault(\"DJANGO_SETTINGS_MODULE\", \"project.settings\")\n\n    application = get_wsgi_application()\n\nThat's it. Now go 12 factor the crap out of something.\n\nCommon problems\n---------------\n\n``AttributeError: module 'dotenv' has no attribute 'read_dotenv'``\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nThere is another similar package,\n`python-dotenv \u003chttps://github.com/theskumar/python-dotenv\u003e`__, which also\ncontains a module called ``dotenv``.  If that package is installed, then you\nwill see:\n\n::\n\n    AttributeError: module 'dotenv' has no attribute 'read_dotenv'\n\nTo resolve this, uninstall python-dotenv.\n\n``read_dotenv`` is not reading from my environment file!\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nBy default, variables that are already defined in the environment take\nprecedence over those in your ``.env`` file.  To change this, call\n``read_dotenv(override=True)``.\n\n.. |build-status-image| image:: https://travis-ci.org/jpadilla/django-dotenv.svg\n   :target: https://travis-ci.org/jpadilla/django-dotenv\n.. |pypi-version| image:: https://img.shields.io/pypi/v/django-dotenv.svg\n   :target: https://pypi.python.org/pypi/django-dotenv\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjpadilla%2Fdjango-dotenv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjpadilla%2Fdjango-dotenv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjpadilla%2Fdjango-dotenv/lists"}