django - Server error loading static files

前端 未结 3 1142
野性不改
野性不改 2021-01-21 14:08

So im building my own django site. Right now im stuck with loading the statics. im getting the following error in the console:

 GET http://localhost:8000/static/         


        
相关标签:
3条回答
  • 2021-01-21 14:48
    Change the your debug into DEBUG=False
    
    0 讨论(0)
  • 2021-01-21 14:54

    Well, I had the same problem, and then I saw this error message:

    "Your STATICFILES_DIRS setting is not a tuple or list; " django.core.exceptions.ImproperlyConfigured: Your STATICFILES_DIRS setting is not a tuple or list; perhaps you forgot a trailing comma?"

    So, I converted the result of

    (os.path.join(BASE_DIR, 'static'))
    

    To a list:

    STATICFILES_DIRS = [(os.path.join(BASE_DIR, 'static'))]
    

    Hope this help somebody.

    0 讨论(0)
  • 2021-01-21 14:59

    You have STATIC_ROOT in STATICFILES_DIRS ! That's incorrect.

    Not sure if your issue is related to that, but it definitively show a lack of understanding of django staticfiles management.

    Maybe after reading this article you'll understand it fully and be able to set it up right.

    And you don't need this with DEBUG=True:

    urlpatterns += patterns('',
    (r'^static/(?P<path>.*)$',
    'django.views.static.serve',
    {'document_root': settings.STATIC_ROOT}),
    )
    
    0 讨论(0)
提交回复
热议问题