Tuesday, 9 February 2016

Django MySQL settings

Due to the fact that I couldn't find anywhere that actually spelled it out explicitly, here's the minimum you need in your settings.py file if you're using a MySQL DB for your Django project and you're using an external DB server (ie, not localhost):

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'name',
        'HOST': '192.168.0.1',
        'PORT': '3306',
        'USER': 'user',
        'PASSWORD': 'password'
    }
}

It's probably obvious to everyone, but who knows - it might save someone some hassle some day.

No comments:

Post a Comment