How to manage development and production settings in django

0 votes
I have been developing a basic app. Now at the deployment stage it has become clear I have need for both a local settings and production settings.

It would be great to know the following:

How best to deal with development and production settings and how to keep apps such as django-debug-toolbar only in a development environment?
Aug 12, 2020 in Python by kartik
• 37,530 points
538 views

1 answer to this question.

0 votes

Hello @kartik,

I usually have one settings file per environment, and a shared settings file:

/myproject/
  settings.production.py
  settings.development.py
  shared_settings.py

Each of my environment files has:

try:
    from shared_settings import *
except ImportError:
    pass

This allows me to override shared settings if necessary (by adding the modifications below that stanza).

I then select which settings files to use by linking it in to settings.py

Hope it helps!!

Thank you!!

answered Aug 12, 2020 by Niroj
• 82,820 points

Related Questions In Python

0 votes
1 answer

How to run django unit-tests on production database in Python?

In case someone googles here searching for ...READ MORE

answered Nov 28, 2018 in Python by Nymeria
• 3,520 points
625 views
0 votes
1 answer

How to set NotebookApp.iopub_data_rate_limit and others NotebookApp settings in JupyterHub?

Open the command line and enter jupyter notebook ...READ MORE

answered Jun 10, 2019 in Python by SDeb
• 13,290 points
5,795 views
+1 vote
1 answer

How to create a file and save it to a model's FileField in Django?

Hello @kartik, Basically, a field declared as a FileField, ...READ MORE

answered Jun 30, 2020 in Python by Niroj
• 82,820 points
6,138 views
0 votes
1 answer
0 votes
1 answer

How to temporarily disable a foreign key constraint in MySQL?

Hello @kartik, To turn off foreign key constraint ...READ MORE

answered Jun 23, 2020 in Python by Niroj
• 82,820 points
920 views
0 votes
1 answer

How do I use Django templates without the rest of Django?

Hello @kartik, Let's say you have this important ...READ MORE

answered Jun 23, 2020 in Python by Niroj
• 82,820 points
415 views
0 votes
1 answer

How to manage local vs production settings in Django?

Hello @kartik, In settings.py: try: from local_settings ...READ MORE

answered Jun 22, 2020 in Python by Niroj
• 82,820 points
246 views
0 votes
1 answer

How to secure APIs for Registration and Login in Django Rest Framework?

Hello @kartik, you cannot have an authentication system ...READ MORE

answered Jun 25, 2020 in Python by Niroj
• 82,820 points
1,890 views