目录
开设路径
# 个人站点页面
re_path('^(?P<username>\w+)/$', views.site),
视图函数返回页面
# 个人站点页面
def site(request, username):
# 根据用户名查询用户信息
user_obj = models.UserInfo.objects.filter(username=username).first()
print(user_obj)
if not user_obj:
return render(request, '404.html')
return render(request, 'site.html')
仿博客园404页面
<html><head>
<meta charset="utf-8">
<link rel="icon" href="//common.cnblogs.com/favicon.ico" type="image/x-icon">
<title>404 页面不存在 - 博客园</title>
<style type="text/css">
body {
margin: 8% auto 0;
max-width: 400px;
min-height: 200px;
padding: 10px;
font-family: 'PingFang SC', 'Microsoft YaHei', 'Helvetica Neue', 'Helvetica', 'Arial', sans-serif;
font-size: 14px;
padding-right: 200px;
position: relative;
}
p { color: #555;margin: 15px 0px; }
img { border: 0px; }
.d { color: #404040; }
.robot img { max-width: 192px; }
.robot { position: absolute; top: 0; right: 0; }
</style>
<style type="text/css">#_copy{align-items:center;background:#4494d5;border-radius:3px;color:#fff;cursor:pointer;display:flex;font-size:13px;height:30px;justify-content:center;position:absolute;width:60px;z-index:1000}#select-tooltip,#sfModal,.modal-backdrop,div[id^=reader-helper]{display:none!important}.modal-open{overflow:auto!important}._sf_adjust_body{padding-right:0!important}.super_copy_btns_div{position:fixed;width:154px;left:10px;top:45%;background:#e7f1ff;border:2px solid #4595d5;font-weight:600;border-radius:2px;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,PingFang SC,Hiragino Sans GB,Microsoft YaHei,Helvetica Neue,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;z-index:5000}.super_copy_btns_logo{width:100%;background:#4595d5;text-align:center;font-size:12px;color:#e7f1ff;line-height:30px;height:30px}.super_copy_btns_btn{display:block;width:128px;height:28px;background:#7f5711;border-radius:4px;color:#fff;font-size:12px;border:0;outline:0;margin:8px auto;font-weight:700;cursor:pointer;opacity:.9}.super_copy_btns_btn:hover{opacity:.8}.super_copy_btns_btn:active{opacity:1}</style></head>
<body>
<p style="margin-left: 5px;"><a href="https://www.cnblogs.com/"><img src="/static/img/logo.svg" style="height:45px" alt="cnblogs"></a></p>
<div style="margin-top:20px">
<p style=""><b style="">404.</b> 抱歉,您访问的资源不存在。</p>
<p class="d">可能是网址有误,或者对应的内容被删除,或者处于私有状态。</p>
<p style="color:#777;">代码改变世界,联系邮箱 [email protected]</p>
<p><a href="https://www.cnblogs.com/cmt/p/17320765.html">园子的商业化努力-困境求助:开设捐助通道</a></p>
</div>
<div class="robot"><a href="//www.cnblogs.com/cmt/articles/13940458.html"><img src="/static/img/img_4.png" alt="404 robot"></a></div>
<script async="" src="https://www.googletagmanager.com/gtag/js?id=G-4CQQXWHK3C"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-4CQQXWHK3C');
</script>
</body></html>
ps:图片防盗链
在请求头里面有个参数 referer参数可以区分出地址是从哪来的
referer参数指代的是上一次访问的路径地址,就是你这个地址是从哪过来的