Look through https://code.djangoproject.com/wiki/SplitSettings for many
different approaches to loading settings from files that aren't importable
as Python modules.

My personal favorite is django-split-settings, which would let you
accomplish exactly what you're trying to do.


On Thu, Apr 6, 2017 at 9:50 AM, Tobias McNulty <tob...@caktusgroup.com>
wrote:

> I don't see Django making a change like this. If it's really impossible to
> get your production settings file on an already-importable Python path, you
> *could* modify your PYTHONPATH
> <https://docs.python.org/3/using/cmdline.html#envvar-PYTHONPATH>
> environment variable to add the directory containing your Django settings
> file. That being said, I think you're better off keeping all your settings
> files in version control where they belong, and changing the things you
> need to change via environment variables.
>
> On Thu, Apr 6, 2017 at 9:20 AM, James Pic <j...@yourlabs.org> wrote:
>
>> Hi all!
>>
>> Life with DJANGO_SETTINGS_MODULE has been great. However, it requires the
>> settings to be an importable module. In most cases, this is a straight
>> forward "simple" python script.
>>
>> Sometimes it looks like it could make sense to add an environment
>> variable that could use a file that is not importable as a python module,
>> ie.:
>>
>> DJANGO_SETTINGS_FILE=/etc/yourapp/production.py
>> DJANGO_SETTINGS_FILE=~/yourapp_production.py
>> DJANGO_SETTINGS_FILE=settings.py  # relative to pwd
>>
>> Then, in this file, we could override the default project settings there
>> without having to put the new file in an importable module, ie. in
>> /etc/yourapp/production.py:
>>
>> from yourapp.settings import *
>> DATABASES=...
>> CACHES=...
>> SECRET_KEY=...
>>
>> I'm sure this has been discussed before but didn't find anything by
>> searching DJANGO_SETTINGS_FILE in the ML.
>>
>> What's your opinion on this ? Is it time to upgrade this ?
>>
>> Best,
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django developers (Contributions to Django itself)" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-developers+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-developers@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-developers.
>> To view this discussion on the web visit https://groups.google.com/d/ms
>> gid/django-developers/CAC6Op19-0JeL8Jdcq70-pvwz%2Bi2hfKtopEv
>> ihca_rGfH1DrPww%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-developers/CAC6Op19-0JeL8Jdcq70-pvwz%2Bi2hfKtopEvihca_rGfH1DrPww%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
>
>
> *Tobias McNulty*Chief Executive Officer
>
> tob...@caktusgroup.com
> www.caktusgroup.com
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django developers (Contributions to Django itself)" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-developers+unsubscr...@googlegroups.com.
> To post to this group, send email to django-developers@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-developers.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-developers/CAMGFDKThapJkEykuhxFEuTF%2BZNjHNr7t6p%
> 3Dssenb0qM85DVXyQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-developers/CAMGFDKThapJkEykuhxFEuTF%2BZNjHNr7t6p%3Dssenb0qM85DVXyQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/CAH%2BKTJ6nisgP7AC99V0S0zkYGPVu_5oKQCF%3DQ39XEz_0%3Dn9B_Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to