无法加载静态文件Django 1.9

时间:2018-11-24 11:59:36

标签: django

模板找不到静态文件并将其加载到页面上。 这是我的设置:

import os

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
TEMPLATE_DIR = os.path.join(BASE_DIR,'cargo/templates')
# STATIC_DIR = os.path.join(BASE_DIR,'cargo/static')

DEBUG = True

ALLOWED_HOSTS = []

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [TEMPLATE_DIR],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

WSGI_APPLICATION = 'mysite.wsgi.application'

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.9/howto/static-files/

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

STATIC_ROOT = 'os.path.join(os.path.expanduser("~"),       "domains/h2h.su/static/")'

这是我将货物/静态/货物/图像和模板归档在货物应用程序cargo / templates / cargo / index.html中的同一路径的路径

有人可以帮我吗?

1 个答案:

答案 0 :(得分:0)

尝试更改</events>os.path.join(BASE_DIR, "static"),