Guys please tell me why there is no access to CSS. The link in the template correctly substitutes, there are these css files, but when you try to follow this link, we get Page not found (404).

Connection in the template:

{% load staticfiles %} <!— Bootstrap core CSS —> <link href="{% static "css/bootstrap.min.css" %}" rel="stylesheet"> <!— Custom styles for this template —> <link href="{% static "css/blog.css" %}" rel="stylesheet"> 

In Settings.py

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

Collectstatic made.

At the exit in the template:

When transitioning PAge not found http://127.0.0.1:8000/static/css/bootstrap.min.css to Urls.py ] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

  • Do you have debug enabled? Staticfiles only works with it - andreymal

2 answers 2

Check in the settings.py file Debug=True

If you need a warm project, you need to connect your static-server. Django does not perform such functions.

    You have the same quotes in quotes.

     <link href="{% static "css/bootstrap.min.css" %}" rel="stylesheet"> 

    fix on

     <link href="{% static 'css/bootstrap.min.css' %}" rel="stylesheet"> 

    • This is good, but not critical and is not the cause of the problem (the template engine perceives the html-code as an ordinary text) - andreymal