在pythonanywhere上部署Django项目时,Admin css不会加载

时间:2018-01-14 09:00:28

标签: python django pythonanywhere

所以当我尝试部署静态文件时,我遇到了一些麻烦...事情就是我设法服务主静态文件,除管理员外,一切正常。我想我的配置可能有问题。以下是我的网页截图:https://i.imgur.com/RtuStM2.png这是我的settings.py:



BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(file)))

TEMPLATE_DIR = os.path.join(BASE_DIR, 'templates') STATIC_DIR = os.path.join(BASE_DIR, 'static') MEDIA_DIR = os.path.join(BASE_DIR, 'media')

SECRET_KEY = 'ie&_vj_d)t5itbpun3%58tlw(3=ptn1^5qj43kgm^&_z^!5('

DEBUG = False

ALLOWED_HOSTS = ['danielcirstea.pythonanywhere.com']

INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'rango', 'registration' ]

MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'django.middleware.locale.LocaleMiddleware' ]

ROOT_URLCONF = 'tango_with_django_project.urls'

TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [TEMPLATE_DIR, ], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', 'django.template.context_processors.media' ], }, }, ]

WSGI_APPLICATION = 'tango_with_django_project.wsgi.application'

LANGUAGE_CODE = 'ro'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True

STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') STATICFILES_DIRS = [STATIC_DIR, ] STATIC_URL = '/static/'

MEDIA_ROOT = MEDIA_DIR MEDIA_URL = '/media/'

REGISTRATION_OPEN = True ACCOUNT_ACTIVATION_DAYS = 7 REGISTRATION_AUTO_LOGIN = True LOGIN_REDIRECT_URL = '/rango/' LOGIN_URL = '/accounts/login/'




1 个答案:

答案 0 :(得分:1)

首先要做的事情 - 设置文件中的SECRET_KEY是您需要保密的内容,此帖子是公开可见的,因此您现在应该更改它以确保安全。

关于admin CSS,静态文件设置中的第一行看起来不对 - 我认为" URL"在那一行应该是/static/admin。如果你改变了,然后从" Web"重新加载网站。页面,管理员CSS应该开始工作。