我在为我创建的 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 = …Run Code Online (Sandbox Code Playgroud) python django static-files amazon-web-services amazon-elastic-beanstalk