A
A
Antigo_ptz2017-02-16 13:38:02
Django
Antigo_ptz, 2017-02-16 13:38:02

How to move a Django settings file out of a project?

The question is:
The project has a settings folder with three settings files: base.py, local.py, production.py.
production.py inherits base.py settings, overrides some, adds some. Is it possible to somehow move this file from the project folder to a separate folder and connect it so that everything works correctly in production?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
S
sim3x, 2017-02-16
@sim3x

In __init__.py determine where the project is running and port the desired config

A
Artyom Innokentiev, 2017-02-16
@artinnok

What for? Do it in this way:

python manage.py runserver --settings config.settings.production

F
Fadi Haj, 2017-02-17
@fdhaj

Perhaps this option will work for you:

- n
  |-- base.py
- settings
  |-- local.py
  |-- production.py

Let's say the base.py file is located in the n directory and you need to reference it from production.py.
At some point, we do this ln -sf n/base.py settings/base.py.
And in production.py we still do this:
from .base import *

R
retspen, 2017-02-23
@retspen

A great example of how to do this
https://github.com/sixfeetup/ElevenNote/tree/maste...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question