Tell me how to enter the relative paths in the project Django? I want all the paths to be written not rigidly, but relatively, including the database, now I somehow didn’t get very well, I started the project on localhost, but the admin looks like ... nothing! Unformatted, without tables, a single bare HTML and DB is not created in the root of the project, but in the root of MySQL. Tell me how to do it right!
from os import path #SITE_ROOT = os.path.dirname(os.path.realpath(__file__)) DEBUG = True TEMPLATE_DEBUG = DEBUG ADMINS = ( ('admin', 'ow@gmail.com'), ) MANAGERS = ADMINS EMAIL_USE_TLS = True EMAIL_HOST = 'smtp.gmail.com' EMAIL_HOST_USER = 'ow@gmail.com' EMAIL_HOST_PASSWORD = 'yourpassword' EMAIL_PORT = 587 DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'dev', 'USER': 'root', 'PASSWORD': '', 'HOST': '', 'PORT': '', } } TIME_ZONE = 'Europe/Kiev' LANGUAGE_CODE = 'en-us' SITE_ID = 1 USE_I18N = True USE_L10N = True PROJECT_PATH = path.realpath(path.dirname(__file__)) MEDIA_ROOT = path.join(PROJECT_PATH, 'media') MEDIA_URL = '/media/' STATIC_ROOT = '' STATIC_URL = '/static/' ADMIN_MEDIA_PREFIX = '/admin_media/' STATICFILES_DIRS = ( ) STATICFILES_FINDERS = ( 'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder', # 'django.contrib.staticfiles.finders.DefaultStorageFinder', ) SECRET_KEY = 'o77777777777777777777777k$' TEMPLATE_LOADERS = ( 'django.template.loaders.filesystem.Loader', 'django.template.loaders.app_directories.Loader', # 'django.template.loaders.eggs.Loader', ) MIDDLEWARE_CLASSES = ( 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', ) ROOT_URLCONF = 'site.urls' TEMPLATE_DIRS = ( #os.path.join(SITE_ROOT, 'templates') ) INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.admin', 'posts', # Uncomment the next line to enable admin documentation: # 'django.contrib.admindocs', ) LOGGING = { 'version': 1, 'disable_existing_loggers': False, 'handlers': { 'mail_admins': { 'level': 'ERROR', 'class': 'django.utils.log.AdminEmailHandler' } }, 'loggers': { 'django.request': { 'handlers': ['mail_admins'], 'level': 'ERROR', 'propagate': True, }, } } try: from local_settings import * except: pass