Kea*_*New 1 python django static-files amazon-web-services amazon-elastic-beanstalk
我在为我创建的 django 应用程序设置弹性 beantalk 上的静态文件夹时遇到了一些麻烦。我设法让应用程序在没有任何 css/js/etc 的情况下运行。我的文件结构是:
|.ebextensions
| --django.config
|.elasticbeanstalk
| --config.yml
|django_app
| --core
| --blog
| --other apps..
|config
| --settings
| --base.py
| --local.py
| --production.py
| --asgi.py
| --urls.py
| --wsgi.py
|static
| --blog
| --css/js/etc
| --other apps
|manage.py
|requirements.txt
|secrets.json
Run Code Online (Sandbox Code Playgroud)
在我的 django.config 中,我是这样设置的:
option_settings:
aws:elasticbeanstalk:application:environment:
DJANGO_SETTINGS_MODULE: config.settings.production
aws:elasticbeanstalk:container:python:
WSGIPath: config.wsgi:application
NumProcesses: 3
NumThreads: 20
Run Code Online (Sandbox Code Playgroud)
对于我在 base.py 中的静态设置(production/local.py 做 import base.py):
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.0/howto/static-files/
STATIC_URL = '/static/'
STATIC_ROOT = "static"
Run Code Online (Sandbox Code Playgroud)
我在烧瓶上遇到了类似的问题,但它并没有给我带来这么多麻烦。我试图遵循这里的一些解决方案,但还没有奏效,或者我误解了一些东西。任何帮助表示赞赏!
您必须在 django.config 中添加一个附加选项option_settings,这取决于您使用的 Elastic Beanstalk 平台。
我认为您正在使用新平台platform/Python 3.7 running on 64bit Amazon Linux 2。如果是,请使用:
aws:elasticbeanstalk:environment:proxy:staticfiles:
/static: static
Run Code Online (Sandbox Code Playgroud)
但是,如果您正在使用platform/Python 3.6 running on 64bit Amazon Linux或更旧,请使用:
aws:elasticbeanstalk:container:python:staticfiles:
/static: static
Run Code Online (Sandbox Code Playgroud)
您可以查看此链接以获取更多详细信息。
如果你不知道你使用的平台,有不同的方式来了解它:
eb status命令的输出中。| 归档时间: |
|
| 查看次数: |
1294 次 |
| 最近记录: |