Python Django: You're using the staticfiles app without having set the STATIC_ROOT setting

前端 未结 3 1242
盖世英雄少女心
盖世英雄少女心 2021-02-02 07:53

I\'m trying to deploy my Django application to the web, but I get the following error:

You\'re using the staticfiles app without having set the STATIC_ROO

3条回答
  •  情话喂你
    2021-02-02 08:37

    If you are using Django 2.2 or greater, your settings file already has a line similar to this:

    # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
    BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    

    Therefore you can easily set static like so:

    STATIC_URL = '/static/'
    STATIC_ROOT = os.path.join(BASE_DIR, 'static')
    

提交回复
热议问题