django-environ | environ allows you to utilize 12factor inspired environment | Configuration Management library

 by   joke2k Python Version: 0.11.2 License: MIT

kandi X-RAY | django-environ Summary

kandi X-RAY | django-environ Summary

django-environ is a Python library typically used in Devops, Configuration Management applications. django-environ has no bugs, it has no vulnerabilities, it has build file available, it has a Permissive License and it has medium support. You can install using 'pip install django-environ' or download it from GitHub, PyPI.

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

            kandi-support Support

              django-environ has a medium active ecosystem.
              It has 2753 star(s) with 312 fork(s). There are 37 watchers for this library.
              There were 3 major release(s) in the last 12 months.
              There are 57 open issues and 166 have been closed. On average issues are closed in 376 days. There are 10 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of django-environ is 0.11.2

            kandi-Quality Quality

              django-environ has 0 bugs and 0 code smells.

            kandi-Security Security

              django-environ has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              django-environ code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              django-environ is licensed under the MIT License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              django-environ releases are available to install and integrate.
              Deployable package is available in PyPI.
              Build file is available. You can build the component from source.
              django-environ saves you 518 person hours of effort in developing the same functionality from scratch.
              It has 2071 lines of code, 168 functions and 19 files.
              It has high code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi has reviewed django-environ and discovered the below as its top functions. This is intended to give you an instant insight into django-environ implemented functionality, and help decide if they suit your requirements.
            • Return db_url config
            • Safely cast value
            • Convert a string to an integer
            • Return database configuration
            • Get the configuration of a search URL
            • Return the value of a URL
            • Return search configuration for given URL
            • Load long description
            • Find package meta file
            • Read a file
            • Return the version string
            • Return True if the given version is a canonical version
            • Register schemes
            • Register a scheme
            • Find the version string in the project meta file
            • Return a pyemcache driver
            • Return a Path object
            • Read file contents
            Get all kandi verified functions for this library.

            django-environ Key Features

            No Key Features are available at this moment for django-environ.

            django-environ Examples and Code Snippets

            Pythondot img1Lines of Code : 14dot img1License : Permissive (MIT)
            copy iconCopy
            │   │   <-- imports local for compatybility
            │   │       <-- almost all the settings, reads from proces environment 
            │   │      <-- a few modifications for l  
            Django Starter Project, Getting started,2) Set environment variables
            Pythondot img2Lines of Code : 1dot img2License : Permissive (MIT)
            copy iconCopy
            cp .env.example .env
            Improperly Configured DATABASE_NAME env var
            Pythondot img3Lines of Code : 5dot img3License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            heroku config # View config vars
            heroku config:set TEST=test # Sets TEST to "test"
            heroku config:unset TEST # Reverses setting TEST
            heroku config:get TEST # Returns value of TEST
            How to change Django project dynamically for production and staging servers
            Pythondot img4Lines of Code : 31dot img4License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            from django.conf import settings
                def get_cursor():
                    if settings.PROD == settings.DJANGO_HOST:
                        conn = mariadb.connect(
            How do you set Django environment variables with venv on linux?
            Pythondot img5Lines of Code : 8dot img5License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            import environ
            env = environ.Env(
                # set casting, default value
                DEBUG=(bool, False)
            Python Django deployment to Heroku H10 error
            Pythondot img6Lines of Code : 4dot img6License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'backend.settings')
            os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'project.settings') 
            Setting up gitlab CI with simple django project
            Pythondot img7Lines of Code : 35dot img7License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            # requirements.txt
            # .gitlab-ci.yml
            image: python:latest
                SECRET_KEY: "this-is-my-secre
            Django: How to set a new static path in production?
            Pythondot img8Lines of Code : 45dot img8License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            set-placeholder = var_static=/home/user/html/blackbird_assets
            static-map = /static=%(var_static)/static
            static-map = /media=%(var_static)/media
            # Build paths inside the project like this: os
            copy iconCopy
            sudo yum install mysql-devel gcc python-devel
            pip install mysqlclient
            failed getting value from django .env
            Pythondot img10Lines of Code : 4dot img10License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            env = environ.Env()
            frontend_url = env('FRONTEND_URL')

            Community Discussions


            How to install pyodbc on Dockerfile
            Asked 2022-Feb-22 at 13:46

            I'm trying to install pyodbc on Django to access Sql Server but the Docker image had no be built.

            The Dockerfile:



            Answered 2022-Feb-22 at 13:46

            Compiler is simply complaining about a build time dependency, cc1 tool should be in your system to build pyodbc.

            In Ubuntu you can solve this with



            AWS Elastic Beanstalk - Failing to install requirements.txt on deployment
            Asked 2022-Feb-05 at 22:37

            I have tried the similar problems' solutions on here but none seem to work. It seems that I get a memory error when installing tensorflow from requirements.txt. Does anyone know of a workaround? I believe that installing with --no-cache-dir would fix it but I can't figure out how to get EB to do that. Thank you.




            Answered 2022-Feb-05 at 22:37

            The error says MemoryError. You must upgrade your ec2 instance to something with more memory. tensorflow is very memory hungry application.



            Improperly Configured DATABASE_NAME env var
            Asked 2022-Jan-12 at 03:53

            I made a .env file in the same directory as my file and have some environmental variables in there such as: secret_key, database_name, etc. However, it doesn't seem to be reading the database name correctly in the .env file. I feel like I followed the docs, but still get the improperly configured error when pushing to Heroku. It does work when running the server locally though.




            Answered 2022-Jan-12 at 03:53

            As you may have guessed judging by your edit, Heroku doesn't support pushing .env files. This is because it uses an ephemeral filesystem.

            Each dyno gets its own ephemeral filesystem, with a fresh copy of the most recently deployed code. [...] any files written will be discarded the moment the dyno is stopped or restarted. For example, this occurs any time a dyno is replaced due to application deployment and approximately once a day as part of normal dyno management.

            You'd be better off using Heroku's built-in config var support. Here are some examples:



            How do I replace MemcachedCache with PyMemcacheCache in Django?
            Asked 2021-Dec-22 at 02:32

            I'm running my website on Django 3.2. I read in Django’s cache framework that MemcachedCache and python-memcached are deprecated. I installed pymemcache==3.5.0 on my staging server and changed to CACHE_URL=pymemcache:// in env.ini. But if I uninstall python-memcached with pip I receive an error message, that indicates that MemcachedCache is still used by my code, and it fails on import memcache.

            My code uses the following imports:



            Answered 2021-Dec-22 at 02:32

            I don't know why, but the way I restarted my server during deploy doesn't refresh env.ini, and the server remembers the old settings. If I restart my server with sudo reboot, with the same settings, then CACHES is equal to {'default': {'BACKEND': 'django.core.cache.backends.memcached.PyMemcacheCache', 'LOCATION': ''}} and the site works properly. And I confirmed that if I put dummy values in env.ini then the site doesn't work at all. But only if I restart my server with sudo reboot.



            django.db.utils.OperationalError: no such table: django_session
            Asked 2021-Nov-18 at 09:10

            Premise: I'm a starter[Plz be kind and patient] When i try to run commands in the terminal like:



            Answered 2021-Nov-18 at 09:10

            The most pressing problem here is that you're doing a database call at import time by trying to load a session via



            Reading django_settings from Google Cloud Platform's Secret Manager does not work
            Asked 2021-Oct-23 at 10:35

            When running the command python makemigrations locally on my laptop, I get the following error on my console:



            Answered 2021-Oct-23 at 10:35

            This is apparently caused by two things:

            • In, the secret content is loaded into environment variables with env.read_env(io.StringIO(payload)), as mentioned in the question. That read_env() function apparently does the following:



            Docker Image > 1GB in size from python:3.8.3-alpine
            Asked 2021-Aug-05 at 12:47

            I'm pretty new to docker and, although I've read lots of articles, tutorials and watched YouTube videos, I'm still finding that my image size is in excess of 1 GB when the alpine image for Python is only about 25 MB (if I'm reading this correctly!).

            I'm trying to work out how to make it smaller (if in fact it needs to be).

            [Note: I've been following tutorials to create what I have below. Most of it makes sense .. but some of it feels like voodoo]

            Here is my Dockerfile:



            Answered 2021-Aug-05 at 01:39

            welcome to Docker! It can be quite the thing to wrap one's head around, especially when beginning, but you're asking really valid questions that are all pertinent

            Reducing Size How to

            A great place to start is Docker's own Dockerfile best practices page:


            They explain neatly how your each directve (COPY, RUN, ENV, etc) all create additional layers, increasing your containers size. Importantly, they show how to reduce your image size by minimising the different directives. They key to alot of minimisation is chaining commands in RUN statements with the use of &&.

            Something else I note in your Dockerfile is one specific line:



            Error when hiding django secret_key in miniconda environment
            Asked 2021-Jun-24 at 16:46

            I'm a total newbie and I'm trying to do this project this is my first time, and it's almost done. I tried every method mentioned in this SO thread to move secret key from settings. In every method i got some kind of error, even from this official django doc mathod. I couldn't find where I'm making mistake.

            When the secret key is inside the, everything is working super smooth. But I need to push my code in git, so i have to hide it from

            Right now im adding the details when i tried using django-environ, to keep secret key outside of

            im putting the contents inside the root project folder.

            im using miniconda: 4.10.1. here is my requirement.txt.



            Answered 2021-Jun-23 at 18:01

            First check that you have installed django-environ and maybe you have a typing mistake in your requirements.txt it should be django-environ=0.4.5 instead of django-environ=0.4.5=py_1 you can pass the path of your .env inside read_env(env_file="relative_path_of_your_env_file")

            it read a .env file into os.environ.

            If not given a path to a dotenv path, does filthy magic stack backtracking to find and then find the dotenv.

            go through this code



            Django unittest in Docker container : ModuleNotFoundError: No module named 'code.x'; 'code' is not a package
            Asked 2021-May-22 at 14:41

            this is my first project with Django and also my first time using Docker. So far I'm really enjoying both of them but I'm facing a problem I couldn't resolve after a week.

            I followed this tutorial to build my project :

            So far, my project structure looks like like this :



            Answered 2021-May-22 at 14:39

            Answering my own question as I have FINALLY found the cause of all my troubles ...

            I had created an file at the root of my project to define a project version as a constant..

            After reading here and there about Django modules and namespaces, I removed the from my root directory and that solved the problem.

            **edited my question above to show the file in question



            Python Django deployment to Heroku H10 error
            Asked 2020-Dec-09 at 14:45

            I am trying to deploy API made in Python to to Heroku. I am getting this errors and I do not know how to fix them.



            Answered 2020-Dec-09 at 12:04

            Your had a wrong setting for the settings location



            Community Discussions, Code Snippets contain sources that include Stack Exchange Network


            No vulnerabilities reported

            Install django-environ

            You can install using 'pip install django-environ' or download it from GitHub, PyPI.
            You can use django-environ like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.


            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
          • PyPI

            pip install django-environ

          • CLONE
          • HTTPS


          • CLI

            gh repo clone joke2k/django-environ

          • sshUrl


          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link

            Explore Related Topics

            Consider Popular Configuration Management Libraries


            by mathiasbynens


            by hashicorp


            by spf13


            by Netflix


            by kelseyhightower

            Try Top Libraries by joke2k


            by joke2kPython


            by joke2kPython


            by joke2kPython


            by joke2kPython


            by joke2kHTML