How to start a Django development server with a different database option (not the default)

I have different configurations for the django database in the settings, one of which is called "default" and the other is "clean".

How can I start a development server ( python manage.py runserver ip:port) that binds a clean database option, and not the default?

+5
source share
2 answers

You can save 2 different settings.py parameters and do manage.py at runtime: python manage.py runningerver --settings = [project_name]. [settings file].

modify the settings file to suit your database.

+5
source
if DEBUG:
    DATABASES = {
        'clean': {
            'ENGINE': 'django.db.backends.',
            'NAME': '',
            'USER': '',
            'PASSWORD': '',
            'HOST': '',
            'PORT': '',
            },
        }
else:
    DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.',
            'NAME': '',
            'USER': '',
            'PASSWORD': '',
            'HOST': '',
            'PORT': '',
            },
        }
+3
source

All Articles