我在开发环境中部署文件时遇到问题。
请参阅下面的配置。
python manage.py collectstatic
按预期收集所有文件'/Users/vikingosegundo/Projects/website/media/'
并将它们存储在/Users/vikingosegundo/Projects/website/mydjangoproject/static/
.
但是,虽然使用时 css 文件的链接是正确的<link href="{% static "css/style.css"%}" rel="stylesheet" type="text/css">
(呈现为),但将部署<link href="/staticmedia/css/style.css" rel="stylesheet" type="text/css">
原始文件,而不是来自.
即使我删除./Users/vikingosegundo/Projects/website/media/
STATIC_ROOT
/Users/vikingosegundo/Projects/website/mydjangoproject/static/
/Users/vikingosegundo/Projects/website/media/
我的错误配置在哪里?
设置.py
MEDIA_ROOT = '/Users/vikingosegundo/Projects/website/mydjangoproject/media/'
MEDIA_URL = '/sitemedia/'
STATIC_ROOT = '/Users/vikingosegundo/Projects/website/mydjangoproject/static/'
STATIC_URL = '/staticmedia/'
STATICFILES_DIRS = [
'/Users/vikingosegundo/Projects/website/media/',
]
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)
TEMPLATE_CONTEXT_PROCESSORS = (
'django.contrib.auth.context_processors.auth',
'django.core.context_processors.debug',
'django.core.context_processors.i18n',
'django.core.context_processors.media',
'django.core.context_processors.static',
)
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
#....
)