添加404界面

This commit is contained in:
小钊 2025-07-01 19:36:03 +08:00
parent a0192e5650
commit 7456441f41
6 changed files with 349 additions and 15 deletions

Binary file not shown.

291
home/static/404.css Normal file

File diff suppressed because one or more lines are too long

39
home/templates/404.html Normal file
View File

@ -0,0 +1,39 @@
{% load static %}
<html lang="en"><head>
<meta charset="UTF-8">
<title>404页面</title>
<link rel="stylesheet" href="{% static '404.css' %}">
</head>
<body>
<div class="error">
<div class="wrap">
<div class="404">
<pre><code>
<span class="green">&lt;!</span><span>DOCTYPE html</span><span class="green">&gt;</span>
<span class="orange">&lt;html&gt;</span>
<span class="orange">&lt;style&gt;</span>
* {
<span class="green">everything</span>:<span class="blue">awesome</span>;
}
<span class="orange">&lt;/style&gt;</span>
<span class="orange">&lt;body&gt;</span>
ERROR 404!
FILE NOT FOUND!
<span class="comment">&lt;!--The file you are looking for,
is not where you think it is.--&gt;
</span>
<span class="orange"></span>
</code></pre></div><code>
<br>
<span class="info">
<br>
<span class="orange">&nbsp;&lt;/body&gt;</span>
<br>
<span class="orange">&lt;/html&gt;</span>
</span></code>
</div>
</div>
</body></html>

View File

@ -1,4 +1,5 @@
from django.shortcuts import render, HttpResponse
from django.http import HttpResponseNotFound
from pip._vendor.rich.markup import Tag
from home.models import *
@ -88,22 +89,25 @@ def index(request):
return render(request, 'index.html', context=get_artchle())
# 文章页视图函数
def archives(request, id):
i = Articles.objects.get(id=id)
i.read += 1
i.save()
try:
i = Articles.objects.get(id=id)
i.read += 1
i.save()
comments = Comment.objects.filter(archives_id=id).order_by("-comment_time").all()
a = get_archives_info(id)
for c in comments:
com = {
"id": c.id,
"comment_Content": c.comment_content,
"comment_User": c.comment_user,
"comment_Time": c.comment_time,
"qq": c.qq,
}
a["comments"].append(com)
return render(request, 'archives.html', a)
comments = Comment.objects.filter(archives_id=id).order_by("-comment_time").all()
a = get_archives_info(id)
for c in comments:
com = {
"id": c.id,
"comment_Content": c.comment_content,
"comment_User": c.comment_user,
"comment_Time": c.comment_time,
"qq": c.qq,
}
a["comments"].append(com)
return render(request, 'archives.html', a)
except:
return render(request, '404.html')
# 分类页视图函数
def category(request,id):
return render(request, 'index.html', context=get_artchle(option=2,id=id))