2

How do I do that? split up 2 files?

TIMEX
  • 238,746
  • 336
  • 750
  • 1,061

4 Answers4

2

Just put it in any file you like and import it somewhere in your main settings file.

So you could set up new settings my_new_settings.py anywhere django can reach, and import it at the end of your real settings.py.

# settings.py
# ...
from my_new_settings import *
Yuji 'Tomita' Tomita
  • 110,403
  • 28
  • 276
  • 239
2

These pages might help: discussion on SO, discussion on djangoproject.com

Community
  • 1
  • 1
Elvis D'Souza
  • 2,173
  • 1
  • 22
  • 30
2

Although my solution is not as complex as the ones above, they fit my simple needs: I have some imports in my settings.py file:

try:
    from settings_local import *
except ImportError:
    pass

try:
    from settings_production import *
except ImportError:
    pass

And then I have a settings_local.py file in my local development folder (which I don't upload to the server) and where I overwrite local settings. Then I have a settings_production.py server where I keep settings needed for the production environment.

You can use this technique to import other settings files as well.

chris
  • 280
  • 1
  • 9
0

Create new_settings.py file to contain part of settings.py, and import that file wherever you need it.

Eugene Yarmash
  • 131,677
  • 37
  • 301
  • 358
Mohammad Efazati
  • 4,686
  • 2
  • 33
  • 50