Use today django When debugging page styles , Failed to import static file . All kinds of methods on the Internet have been tried, but they still don't work . Finally, I saw an article that wrote a lot , I put a piece of code in the live broadcast settings.py in , I didn't expect to succeed . Share with friends in need
This is introduced in the template file Of css style : {% load static %} <link rel="stylesheet" type="text/css" href="{% get_static_prefix%}css/index.css">
Put the following paragraph directly in settings.py At the bottom :
STATICFILES_DIRS = ( os.path.join(os.path.dirname(__file__), '../static/').replace('\\', '/'), )
The static stylesheet was successfully opened 了 .