继承Django管理标头

时间:2018-05-24 08:51:41

标签: django django-admin

我有自己的HTML页面" stat.html"它显示了一些图形,这是我使用此方法answer3创建的自定义索引页面的超链接。 我当前的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页面的链接以及其中的一些内容?

1 个答案:

答案 0 :(得分:0)

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

您现在可能希望在您的网站的其他位置使用它,方法是将其作为上下文插入到模板中。