Django - 运行 collectstatic 以收集静态文件,但改为收集项目目录中的所有文件

问题描述

我正在尝试运行 collectstatic 命令以从应用程序的子目录中收集我的所有静态文件,并将它们部署到我的 Amazon S3 存储桶中。 我尝试按照以下链接中的步骤使用 Zappa:https://romandc.com/zappa-django-guide/walk_static/

运行命令 python /manage.py collectstatic 后,我项目目录中的所有文件都被复制到静态文件夹中。另外,它没有部署到 S3 存储桶中。

这是我的代码

STATIC_URL = '/static/'
STATICFILES_Dirs = [
    # os.path.join(BASE_DIR,"/static"),]
if os.environ.get("collectstatic")=='True':
    # STATICFILES_Dirs += 'static',STATIC_ROOT = os.path.join(BASE_DIR,'test')

#STATIC FILE SETTNGS FOR S3
#Used when we seperate css and js into a static folder
DEFAULT_FILE_STORAGE = "django_s3_storage.storage.S3Storage"

if os.environ.get('stage'):
    STATICFILES_STORAGE = "django_s3_storage.storage.StaticS3Storage"
    AWS_S3_BUCKET_NAME_STATIC = 'static-myapp-'+ os.environ.get('stage')
    # These next two lines will serve the static files directly from the s3 bucket
    AWS_S3_CUSTOM_DOMAIN = '%s.s3.amazonaws.com' % AWS_S3_BUCKET_NAME_STATIC
    STATIC_URL = "https://%s/" % AWS_S3_CUSTOM_DOMAIN
else:
    STATICFILES_Dirs+=BASE_DIR,# AWS BUCKET FOR UPLOADED FILES
AWS_S3_UPLOAD_BUCKET = "myapp-uploads"

谁能指出我做错了什么?谢谢!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)