继承 Django 管理员头



我有自己的HTML页面"stat.html",它显示了一些图表,这是我使用此方法get3制作的自定义索引页面的超链接。 我当前的 admin/custom_admin.html 页面如下所示

{% extends "admin/index.html" %}
{% block content %}
{{block.super}}
<div class="module">
<table style="width:100%">
<caption>
<a class="section">Statistics </a>
</caption>
<tbody>
<th scope="row">
<a href="/myapp/statpage" class="model">Stats Page</a>
</th>
</tbody>
</table>
</div>
{% endblock %}

链接/myapp/statpage 是指向静态 html 页面的链接,它在其中显示了两个谷歌图表,如下所示

{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Stats</title>
<script src = 
"https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"> 
</script>
<script type = "text/javascript" src = 
"https://www.gstatic.com/charts/loader.js"> </script>
<script type = "text/javascript"> google.charts.load('current', 
{packages: ['corechart']}); </script>
<script src="{% static "v_stats.js" %}"></script>
</head>
<body>
<div id="container" style="width:80%; height:35vw; margin:"auto";"></div>
<div id="container1" style="width:80%; height:35vw; margin:"auto";"></div>
</body>
</html> 

我如何继承这个 stat.html 页面中的 Django 管理员标头并拥有自己的标题、一些指向静态 js 页面的链接以及其中的一些内容?

from myproject.admin import admin_site
admin.site.site_header = 'My administration'

您现在可能希望将其作为上下文插入到模板中的其他位置。

最新更新