5

i have different configurations for django database in settings, one named "default" and one named "clean".

How i can run the development server (python manage.py runserver ip:port) binding the "clean" database setting and not the default?

2 Answers 2

5

You can hold 2 different settings.py and while run manage.py do : python manage.py runserver --settings=[projectname].[settingsfile].

change the settingsfile according to your database.

Sign up to request clarification or add additional context in comments.

1 Comment

thank you, i've missed that in the docs (maybe it's not there?) i've created another file settings who copies the standard default settings and changes the database
3
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 Comments

i dont like this because even if it's correct i have to load different databases for different purposes when DEBUG is True, so it's not enough
You should never use debug in a live environment, the server email setting is for that purpose
i have different databases in local environment, one to create fixture for test, the other for development. that's why it's not enough. of course in live envinronment DEBUG is False!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.