All Projects → joke2k → Django Environ

joke2k / Django Environ

Licence: mit
Django-environ allows you to utilize 12factor inspired environment variables to configure your Django application.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Django Environ

Django Admin Interface
django's default admin interface made customizable. popup windows replaced by modals. :mage: ⚡️
Stars: ✭ 717 (-70.43%)
Mutual labels:  settings, django
Django Dynamic Preferences
Dynamic global and instance settings for your django project
Stars: ✭ 238 (-90.19%)
Mutual labels:  settings, django
Dynaconf
Configuration Management for Python ⚙
Stars: ✭ 2,082 (-14.14%)
Mutual labels:  settings, django
Django Split Settings
Organize Django settings into multiple files and directories. Easily override and modify settings. Use wildcards and optional settings files.
Stars: ✭ 684 (-71.79%)
Mutual labels:  settings, django
Django Settings Export
Access Django settings from templates the right way™
Stars: ✭ 167 (-93.11%)
Mutual labels:  settings, django
Django Restfulapi
基于 Django 3.x 的 RESTfulAPI 风格的项目模板,用于快速构建企业级高性能的服务端。
Stars: ✭ 184 (-92.41%)
Mutual labels:  django
Dcrm
Darwin Cydia Repo Manager - v4 redesigned in Django.
Stars: ✭ 188 (-92.25%)
Mutual labels:  django
Wq
📱🌐📋 wq: a modular framework supporting web / native geographic data collection apps for mobile surveys and citizen science. Powered by Django REST Framework, Redux, React, and Material UI.
Stars: ✭ 182 (-92.49%)
Mutual labels:  django
Django dramatiq
A Django app that integrates with Dramatiq.
Stars: ✭ 181 (-92.54%)
Mutual labels:  django
Djangorestframework Stubs
PEP-484 stubs for django-rest-framework
Stars: ✭ 191 (-92.12%)
Mutual labels:  django
Django Test Migrations
Test django schema and data migrations, including migrations' order and best practices.
Stars: ✭ 188 (-92.25%)
Mutual labels:  django
Turbo Django
An early stage integration of Hotwire Turbo with Django
Stars: ✭ 185 (-92.37%)
Mutual labels:  django
Django Sharding
A sharding library for Django
Stars: ✭ 184 (-92.41%)
Mutual labels:  django
Django Mock Queries
A library for mocking django queryset functions in memory for testing
Stars: ✭ 187 (-92.29%)
Mutual labels:  django
Promansible
PromAnsible, 集成了Prometheuse(基于时间序列数据的服务监控系统)和Ansible(超级简单好用的IT自动化系统),并通过事件报警机制把二者紧密的结合在一起,并配以简单易用的WebUI,真正实现了监控-报警-处理一条龙的全自动化服务。
Stars: ✭ 183 (-92.45%)
Mutual labels:  django
Drf Yasg
Automated generation of real Swagger/OpenAPI 2.0 schemas from Django REST Framework code.
Stars: ✭ 2,523 (+4.04%)
Mutual labels:  django
Django Photo Gallery
Responsive Django Image Gallery Site Sample optimized for performance and mobile devices
Stars: ✭ 179 (-92.62%)
Mutual labels:  django
Python Notifyall
A library which can be used for all types of notifications like SMS, Mail, Push.
Stars: ✭ 185 (-92.37%)
Mutual labels:  django
Django Tutorials
Source code for my free YouTube series on the Django web framework for Python.
Stars: ✭ 188 (-92.25%)
Mutual labels:  django
Restapiswithdjango
Source code for Django for APIs
Stars: ✭ 184 (-92.41%)
Mutual labels:  django

django-environ

Latest version released on PyPi Coverage Status CI Status Sponsors on Open Collective Backers on Open Collective Say Thanks! Package license

django-environ is the Python package that allows you to use Twelve-factor methodology to configure your Django application with environment variables.

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:

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:[email protected]: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')
}

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 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 book and explained in 12factor-django article.

Using django-environ you can stop to make a lot of unversioned settings_*.py to configure your app. See 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

django-environ is released under the MIT / X11 License, its documentation lives at Read the Docs, the code on GitHub, and the latest release on PyPI.

It’s rigorously tested on Python 3.5+, and officially supports Django 1.11, 2.2, 3.0, 3.1 and 3.2.

If you'd like to contribute to django-environ you're most welcome!

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].