【发布时间】:2013-12-09 08:42:30
【问题描述】:
奇怪的是,每次我连续运行 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',
)
【问题讨论】: