2017-12-10 4 views
0

Struktur Projekt:kann nicht geladen werden Statik Django

project_folder 
├── apps 
│ ├── app1 
│ ├── app2 
├── static 
│ ├── css 
│ │ ├── bootstrap.min.css 
│ ├── images 
│ └── js 
│ │ ├── bootstrap.min.js 
├── templates 
│ ├── base 
│ │ ├── base.html 

Hier ist meine settings.py:

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

STATIC_URL = '/static/' 

STATICFILES_DIR = [ 
    STATIC_PATH, 
] 

Ich habe diese Antwort:

[10/Dec/2017 02:43:58] "GET /static/css/bootstrap.min.css HTTP/1.1" 404 1676 
[10/Dec/2017 02:43:58] "GET /static/images/Logo-ISCAV.png HTTP/1.1" 404 1676 
[10/Dec/2017 02:43:58] "GET /static/js/bootstrap.min.js HTTP/1.1" 404 1670 
[10/Dec/2017 02:43:58] "GET /static/js/bootstrap.min.js HTTP/1.1" 404 1670 

Und hier sind einige Schlagworte im HTML

{% load staticfiles %} 
<!DOCTYPE html> 
<html lang="es-CL"> 
<head> 
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> 
    <meta charset="UTF-8"> 
    <title>ISCAV | {% block title %}{% endblock %}</title> 
    <!-- Carga el path de los archivos estaticos y estilos --> 
    <link rel="stylesheet" href="{% static 'css/bootstrap.min.css' %}"> 
    {% block extrastatic %} 
    {% endblock extrastatic %} 
</head> 

Ich kann nicht sehen, was falsch ist.

+0

Bedienen Sie die Website in der Entwicklung mit './manage.py runserver' oder auf einem Produktionsserver? – surfer190

+0

läuft auf DEBUG mit PyCharm, Suche Ich finde, das ist ein Problem in der Regel auf dieser IDE. :/ –

Antwort

0

Ich bin mir nicht sicher, ob dies helfen wird, aber vielleicht versuchen STATIC_ROOT Hinzufügen

Das ist immer meine Methode ..

Ohne sie wird es das App-Verzeichnis als root verwenden, anstatt der Projekt-Stamm :)

STATIC_URL = '/static/' 

STATIC_ROOT = '/' 

STATICFILES_DIRS = (
    os.path.join(BASE_DIR, "static"), 
) 
+1

omg, thx! Das ist schließlich Arbeit!, Suche tief Ich denke, ist ein Problem in der Regel mit PyCharm –

+0

Ohne it, Es wird das App-Verzeichnis als root, anstatt das Projekt root :) – johnashu

Verwandte Themen