Giter Site home page Giter Site logo

Comments (7)

jezdez avatar jezdez commented on May 24, 2024

Hm, I wonder if you could simply move the issue from the server (Apache) into the application (wsgi.py). Couldn't you just use envdir's Python API to load the environment variables before Django initializes completely?
See my blog software for an example: https://github.com/jezdez/jezdez.com/blob/dc7f7bc765b68e285a0e68f026b74c20aaf0e4c6/jezdez/wsgi.py#L22

Note: the used envdir.read function is deprecated, use the envdir.open instead: http://envdir.readthedocs.org/en/latest/api.html#envdir.open

Would that help fix the issue in cookiecutter-django, @pydanny?

from django-configurations.

schacki avatar schacki commented on May 24, 2024

Well, I think as long as you do not want to control any settings from your virtualhost via environemt variables, you are fine. But what about the following situation:

You have 2 envdir directories, one for debugging, one for production. You now have 2 options to load these programmatically:
a) In your manage.py or wsgi.py you want to control der envdir directory to load based on a environment variable. This is basically what you are doing here:
path = parent / 'envs' / os.environ.get('ENVDIR', 'dev')

But this requires that you are able to set this variable in the virtualhost (or somehwere else) and retrieve this value in python somehow. Because otherwise you will always end upt with 'dev'. This wouled be possible based on the approach in SO, but Graham does not like it.
b) you have a dev_manage.py / prod_manage.py as well as a dev_wsgi.py /prod_wsgi.py and control the envdir directory to be opend this way. But this somehow is completely against the idea of django-configuraitons and envdir.

Is there an option c)?

from django-configurations.

schacki avatar schacki commented on May 24, 2024

So just checking where we are: do we agree on the problem? If so, would be be willing to get the Apache Env variables from the request (other than recommended by Graham)

from django-configurations.

jezdez avatar jezdez commented on May 24, 2024

I've just added support for .env files, a different strategy for storing environment variables. See 01e3f58

The bottom line is:

Set the DOTENV setting in your class to a file path that you want to let django-configurations read. They can differ per environment class of course. See http://ddollar.github.io/foreman/#ENVIRONMENT for more info. This is also used on Heroku as .env files during local development with Foreman.

from django-configurations.

pydanny avatar pydanny commented on May 24, 2024

Since I see Apache, mod_wsgi, and environment variables are the title of this issue, it behooves me to point out a downstream issue that was opened for cookiecutter-django: cookiecutter/cookiecutter-django#160

from django-configurations.

jezdez avatar jezdez commented on May 24, 2024

@pydanny Thanks!

I'm a bit sad to see this issue being dragged between that many projects and that some people involved seem to be passive-aggressive about it. That said, it seems to be an issue for some users stuck on Apache so I'll take a look at how to best document it. Probably with the idea of having separate wsgi/*.py files to set the environment variables for each environment. It's an additional chore for the users but that's the gist of my experience with Apache anyway.

from django-configurations.

pydanny avatar pydanny commented on May 24, 2024

@jezdez, Sending you a private email.

from django-configurations.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.