【问题标题】:django collectstatic adding extra /static/ foldersdjango collectstatic 添加额外的 /static/ 文件夹
【发布时间】: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',
)

【问题讨论】:

    标签: python django


    【解决方案1】:

    我想我找到了罪魁祸首,我为 MEDIA_ROOT 设置了这条线

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

    应该是这样的:

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

    更改后,collectstatic 正常工作。

    【讨论】:

      猜你喜欢
      • 2016-10-13
      • 1970-01-01
      • 1970-01-01
      • 2017-02-02
      • 2013-12-30
      • 2020-02-10
      • 2017-12-10
      • 1970-01-01
      • 2012-11-14
      相关资源
      最近更新 更多