奇怪的是,每次我连续运行collectstatic时,它都会将静态文件复制到静态文件夹中的一个额外的静态文件夹中:
我第一次运行它:
Copying '/var/www/django/abc/public-www/static//images/coro.jpg'
第二次运行它时,它将复制文件如下:
Copying '/var/www/django/abc/public-www/static/static/images/coro.jpg'
第三次:
Copying '/var/www/django/abc/public-www/static/static/static/images/coro.jpg'
这就是我在settings.py中所拥有的
PROJECT_ROOT = dirname(dirname(__file__))
VIRTUALENV_ROOT = dirname(PROJECT_ROOT)
STATIC_ROOT = join(VIRTUALENV_ROOT, 'public-www', 'static')
# URL prefix for static files.
# Example: "http://example.com/static/", "http://static.example.com/"
STATIC_URL = '/static/'
# Additional locations of static files
STATICFILES_DIRS = (
# Put strings here, like "/home/html/static" or "C:/www/django/static".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
join(PROJECT_ROOT,'static'),
)
# 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',
)
答案 0 :(得分:0)
我想我找到了罪魁祸首,我有这条线用于MEDIA_ROOT
MEDIA_ROOT = join(VIRTUALENV_ROOT, 'public-www')
应该是:
MEDIA_ROOT = join(VIRTUALENV_ROOT, 'public-www', 'media')
一旦我改变它,collectstatic正常工作。