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 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350
|
Metadata-Version: 2.2
Name: django-environ
Version: 0.12.0
Summary: A package that allows you to utilize 12factor inspired environment variables to configure your Django application.
Home-page: https://django-environ.readthedocs.org
Author: Daniele Faraglia
Author-email: daniele.faraglia@gmail.com
Maintainer: Serghei Iakovlev
Maintainer-email: oss@serghei.pl
License: MIT
Project-URL: Documentation, https://django-environ.readthedocs.org
Project-URL: Funding, https://opencollective.com/django-environ
Project-URL: Say Thanks!, https://saythanks.io/to/joke2k
Project-URL: Changelog, https://django-environ.readthedocs.org/en/latest/changelog.html
Project-URL: Bug Tracker, https://github.com/joke2k/django-environ/issues
Project-URL: Source Code, https://github.com/joke2k/django-environ
Keywords: environment,django,variables,12factor
Platform: any
Classifier: Development Status :: 5 - Production/Stable
Classifier: Framework :: Django
Classifier: Framework :: Django :: 2.2
Classifier: Framework :: Django :: 3.0
Classifier: Framework :: Django :: 3.1
Classifier: Framework :: Django :: 3.2
Classifier: Framework :: Django :: 4.0
Classifier: Framework :: Django :: 4.1
Classifier: Framework :: Django :: 4.2
Classifier: Framework :: Django :: 5.0
Classifier: Framework :: Django :: 5.1
Classifier: Operating System :: OS Independent
Classifier: Intended Audience :: Developers
Classifier: Natural Language :: English
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Utilities
Classifier: License :: OSI Approved :: MIT License
Requires-Python: >=3.9,<4
Description-Content-Type: text/x-rst
License-File: LICENSE.txt
License-File: AUTHORS.rst
Provides-Extra: testing
Requires-Dist: coverage[toml]>=5.0a4; extra == "testing"
Requires-Dist: pytest>=4.6.11; extra == "testing"
Requires-Dist: setuptools>=71.0.0; extra == "testing"
Provides-Extra: docs
Requires-Dist: furo>=2024.8.6; extra == "docs"
Requires-Dist: sphinx>=5.0; extra == "docs"
Requires-Dist: sphinx-notfound-page; extra == "docs"
Provides-Extra: develop
Requires-Dist: coverage[toml]>=5.0a4; extra == "develop"
Requires-Dist: pytest>=4.6.11; extra == "develop"
Requires-Dist: setuptools>=71.0.0; extra == "develop"
Requires-Dist: furo>=2024.8.6; extra == "develop"
Requires-Dist: sphinx>=5.0; extra == "develop"
Requires-Dist: sphinx-notfound-page; extra == "develop"
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: keywords
Dynamic: license
Dynamic: maintainer
Dynamic: maintainer-email
Dynamic: platform
Dynamic: project-url
Dynamic: provides-extra
Dynamic: requires-python
Dynamic: summary
==============
django-environ
==============
``django-environ`` is the Python package that allows you to use
`Twelve-factor methodology <https://www.12factor.net/>`_ to configure your
Django application with environment variables.
.. -teaser-end-
For that, it gives you an easy way to configure Django application using
environment variables obtained from an environment file and provided by the OS:
.. -code-begin-
.. code-block:: python
import environ
import os
env = environ.Env(
# set casting, default value
DEBUG=(bool, False)
)
# Set the project base directory
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Take environment variables from .env file
environ.Env.read_env(os.path.join(BASE_DIR, '.env'))
# False if not in os.environ because of casting above
DEBUG = env('DEBUG')
# Raises Django's ImproperlyConfigured
# exception if SECRET_KEY not in os.environ
SECRET_KEY = env('SECRET_KEY')
# Parse database connection url strings
# like psql://user:pass@127.0.0.1:8458/db
DATABASES = {
# read os.environ['DATABASE_URL'] and raises
# ImproperlyConfigured exception if not found
#
# The db() method is an alias for db_url().
'default': env.db(),
# read os.environ['SQLITE_URL']
'extra': env.db_url(
'SQLITE_URL',
default='sqlite:////tmp/my-tmp-sqlite.db'
)
}
CACHES = {
# Read os.environ['CACHE_URL'] and raises
# ImproperlyConfigured exception if not found.
#
# The cache() method is an alias for cache_url().
'default': env.cache(),
# read os.environ['REDIS_URL']
'redis': env.cache_url('REDIS_URL')
}
.. -overview-
The idea of this package is to unify a lot of packages that make the same stuff:
Take a string from ``os.environ``, parse and cast it to some of useful python
typed variables. To do that and to use the `12factor <https://www.12factor.net/>`_
approach, some connection strings are expressed as url, so this package can parse
it and return a ``urllib.parse.ParseResult``. These strings from ``os.environ``
are loaded from a ``.env`` file and filled in ``os.environ`` with ``setdefault``
method, to avoid to overwrite the real environ.
A similar approach is used in
`Two Scoops of Django <https://web.archive.org/web/20240121133956/https://www.feldroy.com/books/two-scoops-of-django-3-x>`_
book and explained in `12factor-django <https://wellfire.co/learn/easier-12-factor-django>`_
article.
Using ``django-environ`` you can stop to make a lot of unversioned
``settings_*.py`` to configure your app.
See `cookiecutter-django <https://github.com/cookiecutter/cookiecutter-django>`_
for a concrete example on using with a django project.
**Feature Support**
- Fast and easy multi environment for deploy
- Fill ``os.environ`` with .env file variables
- Variables casting
- Url variables exploded to django specific package settings
- Optional support for Docker-style file based config variables (use
``environ.FileAwareEnv`` instead of ``environ.Env``)
.. -project-information-
Project Information
===================
``django-environ`` is released under the `MIT / X11 License <https://choosealicense.com/licenses/mit/>`__,
its documentation lives at `Read the Docs <https://django-environ.readthedocs.io/en/latest/>`_,
the code on `GitHub <https://github.com/joke2k/django-environ>`_,
and the latest release on `PyPI <https://pypi.org/project/django-environ/>`_.
Itβs rigorously tested on Python 3.9+, and officially supports
Django 2.2, 3.0, 3.1, 3.2, 4.0, 4.1, 4.2, 5.0, and 5.1.
If you'd like to contribute to ``django-environ`` you're most welcome!
.. -support-
Support
=======
Should you have any question, any remark, or if you find a bug, or if there is
something you can't do with the ``django-environ``, please
`open an issue <https://github.com/joke2k/django-environ>`_.
Contributing
============
If you would like to contribute to ``django-environ``, please take a look at the
`current issues <https://github.com/joke2k/django-environ/issues>`_. If there is
a bug or feature that you want but it isn't listed, make an issue and work on it.
Bug reports
-----------
*Before raising an issue, please ensure that you are using the latest version
of django-environ.*
Please provide the following information with your issue to enable us to
respond as quickly as possible.
* The relevant versions of the packages you are using.
* The steps to recreate your issue.
* The full stacktrace if there is an exception.
* An executable code example where possible
Guidelines for bug reports:
* **Use the GitHub issue search** β check if the issue has already been
reported.
* **Check if the issue has been fixed** β try to reproduce it using the latest
``main`` or ``develop`` branch in the repository.
* Isolate the problem β create a reduced test case and a live example.
A good bug report shouldn't leave others needing to chase you up for more
information. Please try to be as detailed as possible in your report. What is
your environment? What steps will reproduce the issue? What OS experience the
problem? What would you expect to be the outcome? All these details will help
people to fix any potential bugs.
Feature requests
----------------
Feature requests are welcome. But take a moment to find out whether your idea
fits with the scope and aims of the project. It's up to *you* to make a strong
case to convince the project's developers of the merits of this feature. Please
provide as much detail and context as possible.
Pull requests
-------------
Good pull requests - patches, improvements, new features - are a fantastic
help. They should remain focused in scope and avoid containing unrelated
commits.
Follow this process if you'd like your work considered for inclusion in the
project:
1. Check for open issues or open a fresh issue to start a discussion around a
feature idea or a bug.
2. Fork `the repository <https://github.com/joke2k/django-environ>`_
on GitHub to start making your changes to the ``develop`` branch
(or branch off of it).
3. Write a test which shows that the bug was fixed or that the feature works as
expected.
4. Send a pull request and bug the maintainer until it gets merged and published.
If you are intending to implement a fairly large feature we'd appreciate if you
open an issue with GitHub detailing your use case and intended solution to
discuss how it might impact other work that is in flight.
We also appreciate it if you take the time to update and write tests for any
changes you submit.
**By submitting a patch, you agree to allow the project owner to license your
work under the same license as that used by the project.**
Resources
---------
* `How to Contribute to Open Source <https://opensource.guide/how-to-contribute/>`_
* `Using Pull Requests <https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests>`_
* `Writing good commit messages <https://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html>`_
Release Information
===================
v0.12.0 - 8-November-2024
-----------------------------
Fixed
+++++
- Include prefix in the ``ImproperlyConfigured`` error message
`#513 <https://github.com/joke2k/django-environ/issues/513>`_.
Added
+++++
- Add support for Python 3.12 and 3.13
`#538 <https://github.com/joke2k/django-environ/issues/538>`_.
- Add support for Django 5.1
`#535 <https://github.com/joke2k/django-environ/issues/535>`_.
- Add support for Django CockroachDB driver
`#509 <https://github.com/joke2k/django-environ/issues/509>`_.
- Add support for Django Channels
`#266 <https://github.com/joke2k/django-environ/issues/266>`_.
Changed
+++++++
- Disabled inline comments handling by default due to potential side effects.
While the feature itself is useful, the project's philosophy dictates that
it should not be enabled by default for all users
`#499 <https://github.com/joke2k/django-environ/issues/499>`_.
Removed
+++++++
- Removed support of Python 3.6, 3.7 and 3.8
`#538 <https://github.com/joke2k/django-environ/issues/538>`_.
- Removed support of Django 1.x.
`#538 <https://github.com/joke2k/django-environ/issues/538>`_.
`Full changelog <https://django-environ.readthedocs.org/en/latest/changelog.html>`_.
Security Policy
===============
Reporting a Vulnerability
-------------------------
If you discover a security vulnerability within ``django-environ``, please
send an e-mail to Serghei Iakovlev via oss@serghei.pl. All security
vulnerabilities will be promptly addressed.
Credits
=======
``django-environ`` was initially created by `Daniele Faraglia <https://github.com/joke2k>`_
and currently maintained by `Serghei Iakovlev <https://github.com/sergeyklay/>`_.
A full list of contributors can be found in `GitHub <https://github.com/joke2k/django-environ/graphs/contributors>`__.
Acknowledgments
===============
The existence of ``django-environ`` would have been impossible without these
projects:
- `rconradharris/envparse <https://github.com/rconradharris/envparse>`_
- `jazzband/dj-database-url <https://github.com/jazzband/dj-database-url>`_
- `migonzalvar/dj-email-url <https://github.com/migonzalvar/dj-email-url>`_
- `ghickman/django-cache-url <https://github.com/ghickman/django-cache-url>`_
- `dstufft/dj-search-url <https://github.com/dstufft/dj-search-url>`_
- `julianwachholz/dj-config-url <https://github.com/julianwachholz/dj-config-url>`_
- `nickstenning/honcho <https://github.com/nickstenning/honcho>`_
- `rconradharris/envparse <https://github.com/rconradharris/envparse>`_
|