heroku python运行管理。py collectstatic

时间:2021-10-06 00:57:03

When I run this command I get this error:

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

$ 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'

How can I fix this problem?

我如何解决这个问题?

my settings for static files

我的静态文件设置

# 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

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) –

1 个解决方案

#1


1  

The folder /app/my app/static_in_pro/our_static doesn't exist as mentioned in the error message:

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

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

so create it and any non-existing parent directory than rerun your command.

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

#1


1  

The folder /app/my app/static_in_pro/our_static doesn't exist as mentioned in the error message:

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

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

so create it and any non-existing parent directory than rerun your command.

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