【问题标题】:heroku run python manage.py collectstaticheroku 运行 python manage.py collectstatic
【发布时间】:2016-02-01 08:26:32
【问题描述】:

当我运行这个命令时,我得到这个错误:

$ heroku run python manage.py collectstatic 

Running python manage.py collectstatic on myapp... up, run.1771
You have requested to collect static files at the destination location as specified in your settings:

    /app/static_in_env/static_root

This will overwrite existing files!
Are you sure you want to do this?

Type 'yes' to continue, or 'no' to cancel: 

$ yes

OSError: [Errno 2] No such file or directory: '/app/my app/static_in_pro/our_static'

我该如何解决这个问题?

我的静态文件设置

# Static asset configuration 
STATIC_URL = '/static/'
STATIC_ROOT=os.path.join(os.path.dirname(BASE_DIR),"static_in_env","static_root")
STATICFILES_DIRS = ( os.path.join(BASE_DIR,"static_in_pro","our_static"),  
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(os.path.dirname(BASE_DIR), "static_in_env","media_root") 

urls.py

if settings.DEBUG:
    urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
    urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) –

【问题讨论】:

  • 请显示您的静态文件设置。
  • 这是我对静态文件的设置 # 静态资产配置 STATIC_URL = '/static/' STATIC_ROOT = os.path.join(os.path.dirname(BASE_DIR), "static_in_env","static_root") STATICFILES_DIRS = ( os.path.join(BASE_DIR, "static_in_pro","our_static"), #os.path.join(BASE_DIR, 'static_in_env'), ) MEDIA_URL = '/media/' MEDIA_ROOT = os.path.join( os.path.dirname(BASE_DIR), "static_in_env","media_root") urls.py if settings.DEBUG: urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) urlpatterns += static(settings.MEDIA_URL, document_root =settings.MEDIA_ROOT)
  • 我尝试自己做,但意识到由于格式丢失而不得不进行猜测,因此:请编辑您的问题以包含您的设置。 (另外,包括您的 WSGI;您是否使用 Heroku Django 快速入门建议和紧贴?)
  • 检查目录'/app/my app/static_in_pro/our_static'是否存在于您的服务器中,如果不存在则创建它..如果您无法创建,则将具有值app/my app的变量更改为现有目录跨度>
  • 该目录存在,但就像这个 app/static_in_pro/our_static 一样,我无法从 bash 在 heroku 上的 repo 中创建文件夹

标签: python django heroku static django-staticfiles


【解决方案1】:

错误信息中提到的文件夹/app/my app/static_in_pro/our_static不存在:

OSError: [Errno 2] No such file or directory: '/app/my app/static_in_pro/our_static'

所以创建它和任何不存在的父目录,而不是重新运行您的命令。

【讨论】:

    猜你喜欢
    • 2020-12-05
    • 2017-04-09
    • 2018-11-02
    • 2017-05-21
    • 2017-12-15
    • 2013-07-21
    • 2014-02-04
    • 1970-01-01
    • 2021-02-16
    相关资源
    最近更新 更多