我下载了免费的模板zip文件(包括联系表格,css,字体,img,js,readme.txt文件夹)以使用django模板,然后将主模板粘贴到home.html中。我还按照“良好(应用程序)-静态(文件夹)-良好(文件夹)-联系表,css,字体,img,js,readme.txt(文件夹)”的顺序创建了一个目录。连接所有链接后,我可能需要,但是模板仍然不起作用。你能找到我什么问题吗?
我更改了所有目录路径以为模板建立正确的连接。
home.html中标签的一部分靠近头部标签
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Maundy | Comming Soon Page</title>
<meta name="description" content="Free Bootstrap Theme by BootstrapMade.com">
<meta name="keywords" content="free website templates, free bootstrap themes, free template, free bootstrap, free website template">
<link href='https://fonts.googleapis.com/css?family=Lobster|Open+Sans:400,400italic,300italic,300|Raleway:300,400,600' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="{% static 'good/static/good/css/animate.css' %}">
<link rel="stylesheet" type="text/css" href="{% static 'good/static/good/css/bootstrap.min.css' %}">
<link rel="stylesheet" type="text/css" href="{% static 'good/static/good/css/font-awesome.min.css' %}">
<link rel="stylesheet" type="text/css" href="{% static 'good/static/good/css/style.css' %}">
<!-- =======================================================
Theme Name: Maundy
Theme URL: https://bootstrapmade.com/maundy-free-coming-soon-bootstrap-theme/
Author: BootstrapMade.com
Author URL: https://bootstrapmade.com
======================================================= -->
</head>
<body>
<div class="content">
<div class="container wow fadeInUp delay-03s">
<div class="row">
<div class="logo text-center">
<img src="{% static 'good/static/good/img/banner01.jpg' %}"/>
<h2>We Are Baking Something New!! Comming Soon</h2>
</div>
Designed by <a href="https://bootstrapmade.com/">BootstrapMade</a>
</div>
</div>
</div>
</div>
</footer>
<script src="{% static 'good/static/good/js/bootstrap.min.js' %}"></script>
<script src="{% static 'good/static/good/js/custom.js' %}"></script>
<script src="{% static 'good/static/good/js/jquery.countdown.min.js' %}"></script>
<script src="{% static 'good/static/good/js/jquery.min.js' %}"></script>
<script src="{% static 'good/static/good/js/wow.js' %}"></script>
<script src="{% static 'good/static/good/contactform/contactform.js' %}"></script>
</body>
</html>
{% endblock %}
from django.shortcuts import render, get_object_or_404, redirect
from .models import Good
from django.utils import timezone
def home(request):
return render(request,'home.html')
def new(request):
return render(request, 'new.html')
def create(request):
blog = Good()
blog.title = request.GET['title']
blog.body = request.GET['body']
blog.pub_date = timezone.datetime.now()
blog.save()
return redirect('/blog/' + str(blog.id))
def detail(request,blog_id):
all_objects = Good.objects.all()
details = get_object_or_404(Good, pk= blog_id)
return render(request, 'detail.html', {'details':details,'all_objects':all_objects})
# Create your views here.
urls.py
from django.contrib import admin
from django.urls import path
import good.views
import account.views
urlpatterns = [
path('admin/', admin.site.urls),
path('', good.views.home, name="home"),
path('login/', account.views.login, name="login"),
path('signup/', account.views.signup, name="signup"),
path('new/', good.views.new, name="new"),
path('create/', good.views.create, name="create"),
path('blog/<int:blog_id>', good.views.detail, name="detail"),
]
STATIC_URL = '/static/'
STATICFILES_DIRS = [
os.path.join(BASE_DIR,'good','static')
]
STATIC_ROOT = os.path.join(BASE_DIR,'static')
模板似乎没有调整。请帮帮我!