Django — Can't get static CSS files to load

后端 未结 20 1900
借酒劲吻你
借酒劲吻你 2020-11-29 23:45

I\'m running Django\'s development server (runserver) on my local machine (Mac OS X) and cannot get the CSS files to load.

Here are the relevant entries

20条回答
  •  没有蜡笔的小新
    2020-11-30 00:17

    You can just set STATIC_ROOT depending on whether you are running on your localhost or on your server. To identify that, refer to this post.

    And you can rewrite you STATIC_ROOT configuration as:

    import sys
    
    if 'runserver' in sys.argv:
        STATIC_ROOT = ''
    else:
        STATIC_ROOT = os.path.join(BASE_DIR, 'static')
    STATIC_URL = '/static/'
    

提交回复
热议问题