Django settings.py

Posted under » MySQL » Django on 23 April 2021

From Installing mod_wsgi for django we know we have to

ALLOWED_HOSTS = ['student.com']
WSGI_APPLICATION = 'student_als.wsgi.application'

Now we have to

TIME_ZONE = 'Asia/Singapore'

Switch from SQlite to mysql with this

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql', 
        'NAME': 'dbblog',
        'USER': 'tidak',
        'PASSWORD': 't35nang12',
        'HOST': 'localhost',   
        'PORT': '3306',
    }    
}

You can add another database too perhaps a read only one.

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql', 
        'NAME': 'student',
        'USER': 'anoneh',
        'PASSWORD': 'MrsLKY1',
        'HOST': 'localhost',   
        'PORT': '3306',
        }
    },
    'eauthor': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'LMS_contents',
        'USER': 'anoneh',
        'PASSWORD': 'MrsLKY1',
        'HOST': 'localhost',
        'PORT': '3306',
        'OPTIONS': {
            'init_command': "SET sql_mode='STRICT_TRANS_TABLES'"
        }
    }
}

For any new app created.

INSTALLED_APPS = [
'polls.apps.PollsConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]

You can make URL alias like

LOGIN_URL = 'login'
LOGIN_REDIRECT_URL = 'innerpage'

Static files

STATIC_URL = '/static/'
STATIC_ROOT = "/var/www/dblog/static/"

More on Static files.

web security linux ubuntu python django git Raspberry apache mysql php drupal cake javascript css AWS