Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get the correct properties outside of settings.py according the different configuration #185

Closed
klion26 opened this issue Nov 7, 2017 · 2 comments

Comments

@klion26
Copy link

klion26 commented Nov 7, 2017

I have Some classes inherent from configurations.Configuration In settings.py such as below

class Common(Configuration):
        REDIS_HOST = 'xxx'

class Dev(Common):
        REDIS_HOST = 'dev_xxx'

class Prod(Common):
         REDIS_HOST = 'prod_xxx'

How could I get the correct REDIS_HOST in other python modules in the same project.

AFAIK, I could test the environment which my project running on, so use the correct Class#properties. But, I want to know is there any better solutions for these things.

I read the docs, but didn't find any solutions.

@bittner
Copy link
Member

bittner commented Dec 10, 2018

Your example reads like the server specific usage pattern in the docs. You need to set the environment variable DJANGO_CONFIGURATION to the configuration class name you want to use.

In your code you simply access the Django settings as usual.

Anything else unclear? Should we add something more to the documentation?

@bittner
Copy link
Member

bittner commented Dec 10, 2018

Please see the Django documentation on settings for how to use Django's settings in your Python code.

Feel free to enhance our documentation via a PR if you feel that information is missing and valuable.

@bittner bittner closed this as completed Dec 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants