2013-12-09 48 views
1

这很奇怪的是,每次我跑collectstatic连续它复制静态文件夹中的静态文件到一个额外的静态文件夹:Django的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

我想我已经找到了罪魁祸首,我有这条线MEDIA_ROOT

MEDIA_ROOT = join(VIRTUALENV_ROOT, 'public-www') 

本应是:

MEDIA_ROOT = join(VIRTUALENV_ROOT, 'public-www', 'media') 

一旦我改变了它,collectstatic就像平常一样工作。