当我运行服务器时,django管理员缺少css.网络控制台说没有加载样式表,因为它的MIME类型"application/x-css"不是"text/css".这是我的settings.py文件
Django为mysite项目设置.DEBUG = True TEMPLATE_DEBUG = DEBUG ADMINS = ( # ('Your Name', 'your_email@example.com'), ) MANAGERS = ADMINS DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': 'C:/djangorevision/mysite/sqlite3.db', database 'USER': '', # Not used with sqlite3. 'PASSWORD': '', # Not used with sqlite3. 'HOST': '', 'PORT': '', } } ALLOWED_HOSTS = [] TIME_ZONE = 'America/Chicago' LANGUAGE_CODE = 'en-us' SITE_ID = 1 # If you set this to False, Django will make some optimizations so as not # to load the internationalization machinery. USE_I18N = True # If you set this to False, Django will not format dates, numbers and # calendars according to the current locale. USE_L10N = True USE_TZ = True MEDIA_ROOT = '' MEDIA_URL = '' STATIC_ROOT = 'C:/djangorevision/mysite/static' # URL prefix for static files. # Example: "http://media.lawrence.com/static/" STATIC_URL = '/static/' # Additional locations of static files STATICFILES_DIRS = ( ) # List of finder classes that know how to find static files in # various locations. STATICFILES_FINDERS = ( 'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder', # 'django.contrib.staticfiles.finders.DefaultStorageFinder', ) # Make this unique, and don't share it with anybody. SECRET_KEY = '*4#u_xz-+7cp-x-)w(o*sr1&1$^fa409_d@7!&z%_(93u=@s=o' 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', # Uncomment the next line for simple clickjacking protection: # 'django.middleware.clickjacking.XFrameOptionsMiddleware', ) ROOT_URLCONF = 'mysite.urls' # Python dotted path to the WSGI application used by Django's runserver. WSGI_APPLICATION = 'mysite.wsgi.application' TEMPLATE_DIRS = ( ) INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', 'django.contrib.staticfiles', # Uncomment the next line to enable the admin: 'django.contrib.admin', # Uncomment the next line to enable admin documentation: # 'django.contrib.admindocs', 'polls'
)
LOGGING = { 'version': 1, 'disable_existing_loggers': False, 'filters': { 'require_debug_false': { } }, 'handlers': { 'mail_admins': { 'level': 'ERROR', 'filters': ['require_debug_false'], 'class': 'django.utils.log.AdminEmailHandler' } }, 'loggers': { 'django.request': { 'handlers': ['mail_admins'], 'level': 'ERROR', 'propagate': True,`enter code here` }, } }
Tagliner.. 7
我刚遇到同样的问题.看起来你对Dreamweaver是正确的.将上面提到的字符串添加到settings.py中并没有帮助我.
我.css
在regedit上运行搜索并更改了大多数可疑的注册表项/记录
可能与将.css文件视为application/x-css类型有关
可能与将.css文件扩展名与应用程序打开相关联,尤其是Dreamweaver.
它花了我两次迭代,我不能确定哪一个是正确的镜头,因为它可能需要一些时间来更新一些缓存等.
虽然我在两个地方改了它:
HKEY_LOCAL_MACHINE\SOFTWARE\Classes下\的CSS
HKEY_CLASSES_ROOT \的CSS
我重命名(通过添加前导' - '以便在必要时可以恢复)与.css
文件关联的键/记录与所有应用程序(包括Dreamweaver,Notepad等)相关联,并将.css
文件声明为application/x-css类型.
之后问题得到解决,Django CSS样式正确应用,正如预期的那样.
我刚遇到同样的问题.看起来你对Dreamweaver是正确的.将上面提到的字符串添加到settings.py中并没有帮助我.
我.css
在regedit上运行搜索并更改了大多数可疑的注册表项/记录
可能与将.css文件视为application/x-css类型有关
可能与将.css文件扩展名与应用程序打开相关联,尤其是Dreamweaver.
它花了我两次迭代,我不能确定哪一个是正确的镜头,因为它可能需要一些时间来更新一些缓存等.
虽然我在两个地方改了它:
HKEY_LOCAL_MACHINE\SOFTWARE\Classes下\的CSS
HKEY_CLASSES_ROOT \的CSS
我重命名(通过添加前导' - '以便在必要时可以恢复)与.css
文件关联的键/记录与所有应用程序(包括Dreamweaver,Notepad等)相关联,并将.css
文件声明为application/x-css类型.
之后问题得到解决,Django CSS样式正确应用,正如预期的那样.