0

I'm trying to separate out my dev settings, and while there is a ton of info out there, I'm just going for the cs01's solution in this post here: Django: How to manage development and production settings?

So I was unable to create a settings folder and do it that way as it seems you have to then start rewriting the manage.py file which I don't want to do right now, I'm not that skilled. So the above post has a nice simple solution for what is an internal work only site. However while I am able to set:

DEBUG = False

in the main settings and set it to True in my local, that works well, I am unable to add installed apps, I have tried this in my settings_dev.py

DEBUG = True

INSTALLED_APPS += [
    'django_extensions',
]

So I get INSTALLED_APPS is not defined. how can this be worked around? currently the extra installed apps are sitting at the end of the settings.py file like this:

if os.environ.get('DJANGO_DEVELOPMENT'):
    from .settings_dev import *

    INSTALLED_APPS += [
        'django_extensions',
    ]

Is there an easy way to shift the extra INSTALLED_APPS into my dev settings? I have other extensions I want to add like the debug-toolbar, but that includes extra middleware, so I'm expecting the same situation there also.

iFunction
  • 1,208
  • 5
  • 21
  • 35

1 Answers1

1

Not a complete answer to your question, but answers it for people using dynaconf together with django.

Dynaconf allows you to "merge" lists and dictionaries instead of overriding them (https://www.dynaconf.com/merging/), so that in the config file you can use dynaconf_merge_unique and have something like this:

local: &LOCAL
  <<: *DEVELOPMENT
  INSTALLED_APPS:
    - dynaconf_merge_unique
    - sslserver
    - django_extensions

This causes sslserver and django_extensions to only be installed in the local environments.

Again, sorry that this is specifically a dynaconf answer, but perhaps will be useful to someone reading this question.

jsj
  • 9,019
  • 17
  • 58
  • 103