Django can't find staticfiles with Debug=False and Allowed_Hosts

后端 未结 3 1268
陌清茗
陌清茗 2021-02-20 17:05

Hi all I\'m having trouble solving this issue: If I turn DEBUG to False, I can\'t run manage.py runserver:

CommandError: You must set settings.ALLOWED_HOSTS if D         


        
3条回答
  •  死守一世寂寞
    2021-02-20 17:24

    Okay Here's the very clean solution. you need to use

    DEBUG = False
    DEBUG_PROPAGATE_EXCEPTIONS = True
    

    This way in your logs you can see what is then problem. Whitenoise returns 500 usually when It is missing some file.

    You can see what is missing in you logs. In my case heroku logs were enough.

    for more info: https://docs.djangoproject.com/en/2.0/ref/settings/#debug-propagate-exceptions

提交回复
热议问题