Unable to serve static files like css, js in django python

前端 未结 4 2358
轻奢々
轻奢々 2020-12-06 17:41

I am very new to django, and gone through tutorial for many days , i have started building a small website using django and trying to serve a css f

4条回答
  •  南笙
    南笙 (楼主)
    2020-12-06 18:36

    in settings.py try.

    PROJECT_DIR  = os.path.dirname(__file__)
    ...
    MEDIA_ROOT = os.path.join(PROJECT_DIR,'media')
    MEDIA_URL = '/media/'
    STATIC_ROOT = os.path.join(PROJECT_DIR,'static')
    STATIC_URL = '/static/'
    

    my settings.py file is usually in same directory as static directory

提交回复
热议问题