Amazon Elastic Beanstalk not serving django static files

后端 未结 8 2052
你的背包
你的背包 2021-02-18 19:40

I am trying to put up a simple django app on elastic beanstalk. I thought I had the static parts of the app figured out as it works with heroku and on a server that was set up

相关标签:
8条回答
  • 2021-02-18 20:03

    I struggled for quite a while on that, thinking that the issue was with :

    option_settings:
      "aws:elasticbeanstalk:container:python:staticfiles":
        "/static/": "static/"
    

    But actually my issue was with the other commands in the xxx.config file. basicaly, make sure the other lines are correct.

    If you want to know my personal setup, I used the settings file shown above and I added the static directory in the root of my project. For the settings.py file here is what I had for the static_url and root :

    # Static files (CSS, JavaScript, Images)
    # https://docs.djangoproject.com/en/2.2/howto/static-files/
    
    STATIC_URL = '/static/'
    STATIC_ROOT = 'static'
    

    Hope it helps !

    0 讨论(0)
  • 2021-02-18 20:04

    I did the following to fix static path in beanstalk

    STATIC_URL = '/static/'
    
    BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    STATIC_ROOT = os.path.join(BASE_DIR, 'static')
    
    option_settings:
      ...
      ...
      "aws:elasticbeanstalk:container:python:staticfiles":
        "/static/": "static/"
    
    0 讨论(0)
提交回复
热议问题