在我购买的引导程序模板中,未加载静态文件(只有某些文件可以正确显示)。此错误是由什么引起的?我该怎么解决?
我使用最新版本的django和python3,对于其他模板,从来没有类似的问题。当我选择“插入”选项时,一切看起来都很好。
我的文件夹结构:
-app
-__pycache__
-migrations
-static
-assets
-svg
-illustrations
-main-hero.svg
-templates
-app_rama
manage.py
db
示例:
{% load static %}
[...]
<!-- SVG Background -->
<div id="SVGMainHero" class="col-lg-9 col-xl-7 svg-preloader d-none d-lg-block position-absolute top-0 right-0 pr-0" style="margin-top: 105.6px;">
<figure class="ie-main-hero">
<img class="js-svg-injector" src="{% static 'assets/svg/illustrations/main-hero.svg' %}" alt="Image Description" <!-- DO NOT SEE THIS PHOTOS -->
data-img-paths='[
{"targetId": "#SVGMainHeroImg1", "newPath": "{% static 'assets/img/750x750/img2.jpg' %}"}
]'
data-parent="#SVGMainHero">
</figure>
</div>
[...]
<!-- End SVG Background -->
settings.py
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__)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'app',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'app_rama.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'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 = 'app_rama.wsgi.application'
# Database
# https://docs.djangoproject.com/en/2.1/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
# Password validation
# https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/2.1/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.1/howto/static-files/
STATIC_URL = '/static/'
从浏览器中转出
GET http://127.0.0.1:8000/%7B%%20static%20'assets/vendor/jquery/dist/jquery.min.js net::ERR_ABORTED 404 (Not Found)
(index):1776 GET http://127.0.0.1:8000/%7B%%20static%20'assets/vendor/jquery-migrate/dist/jquery-migrate.min.js net::ERR_ABORTED 404 (Not Found)
(index):1777 GET http://127.0.0.1:8000/%7B%%20static%20'assets/vendor/popper.js/dist/umd/popper.min.js net::ERR_ABORTED 404 (Not Found)
(index):1778 GET http://127.0.0.1:8000/%7B%%20static%20'assets/vendor/bootstrap/bootstrap.min.js net::ERR_ABORTED 404 (Not Found)
(index):1775 GET http://127.0.0.1:8000/%7B%%20static%20'assets/vendor/jquery/dist/jquery.min.js net::ERR_ABORTED 404 (Not Found)
(index):1776 GET http://127.0.0.1:8000/%7B%%20static%20'assets/vendor/jquery-migrate/dist/jquery-migrate.min.js net::ERR_ABORTED 404 (Not Found)
(index):1777 GET http://127.0.0.1:8000/%7B%%20static%20'assets/vendor/popper.js/dist/umd/popper.min.js net::ERR_ABORTED 404 (Not Found)
(index):1778 GET http://127.0.0.1:8000/%7B%%20static%20'assets/vendor/bootstrap/bootstrap.min.js net::ERR_ABORTED 404 (Not Found)
hs.megamenu.js:999 Uncaught ReferenceError: jQuery is not defined
at hs.megamenu.js:999
(anonymous) @ hs.megamenu.js:999
jquery.mCustomScrollbar.concat.min.js:1 Uncaught ReferenceError: jQuery is not defined
at jquery.mCustomScrollbar.concat.min.js:1
at jquery.mCustomScrollbar.concat.min.js:1
(anonymous) @ jquery.mCustomScrollbar.concat.min.js:1
(anonymous) @ jquery.mCustomScrollbar.concat.min.js:1
jquery.validate.min.js:4 Uncaught ReferenceError: jQuery is not defined
at jquery.validate.min.js:4
at jquery.validate.min.js:4
(anonymous) @ jquery.validate.min.js:4
(anonymous) @ jquery.validate.min.js:4
jquery.fancybox.min.js:11 Uncaught TypeError: t is not a function
at jquery.fancybox.min.js:11
at jquery.fancybox.min.js:12
(anonymous) @ jquery.fancybox.min.js:11
(anonymous) @ jquery.fancybox.min.js:12
slick.js:25 Uncaught ReferenceError: jQuery is not defined
at slick.js:25
at slick.js:28
(anonymous) @ slick.js:25
(anonymous) @ slick.js:28
hs.core.js:176 Uncaught ReferenceError: jQuery is not defined
at hs.core.js:176
(anonymous) @ hs.core.js:176
hs.header.js:2194 Uncaught ReferenceError: jQuery is not defined
at hs.header.js:2194
(anonymous) @ hs.header.js:2194
hs.unfold.js:632 Uncaught ReferenceError: jQuery is not defined
at hs.unfold.js:632
(anonymous) @ hs.unfold.js:632
hs.focus-state.js:37 Uncaught ReferenceError: jQuery is not defined
at hs.focus-state.js:37
(anonymous) @ hs.focus-state.js:37
hs.malihu-scrollbar.js:102 Uncaught ReferenceError: jQuery is not defined
at hs.malihu-scrollbar.js:102
(anonymous) @ hs.malihu-scrollbar.js:102
hs.validation.js:131 Uncaught ReferenceError: jQuery is not defined
at hs.validation.js:131
(anonymous) @ hs.validation.js:131
hs.fancybox.js:181 Uncaught ReferenceError: jQuery is not defined
at hs.fancybox.js:181
(anonymous) @ hs.fancybox.js:181
hs.slick-carousel.js:396 Uncaught ReferenceError: jQuery is not defined
at hs.slick-carousel.js:396
(anonymous) @ hs.slick-carousel.js:396
hs.show-animation.js:111 Uncaught ReferenceError: jQuery is not defined
at hs.show-animation.js:111
(anonymous) @ hs.show-animation.js:111
hs.svg-injector.js:85 Uncaught ReferenceError: jQuery is not defined
at hs.svg-injector.js:85
(anonymous) @ hs.svg-injector.js:85
hs.go-to.js:166 Uncaught ReferenceError: jQuery is not defined
at hs.go-to.js:166
(anonymous) @ hs.go-to.js:166
(index):1804 Uncaught ReferenceError: $ is not defined
at (index):1804
任何帮助将不胜感激。