Django admin后台默认模板文件解读

2024-03-2112:36:17后端程序开发Comments412 views字数 2995阅读模式

admin的默认模板位于django/contrib/admin/templates/admin/文件下,文件结构接对应解读说明如下:文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/62533.html

auth/user #系统用户管理页面目录    add_form.html#新增用户    change_password.html#修改密码edit_inline#内置关联结构目录    stacked.html#树形结构      tabular.html#表格结构includes#    fieldset.html#filedset字段模板    object_delete_summary.html#对象删除描述页面widgets#input组件包显示窗口    clearable_file_input.html#文件上传    date.html#日期选择器    foreign_key_raw_id.html#foreignkey选择    many_to_many_raw_id.html#manytomany选择    radio.html#单选    related_widget_wrapper.html#小部件包装期模板    split_datetime.html#日期+时间选择器    time.html#时间选择器    url.html#链接404.html#404页面500.html#500页面actions.html#动作按钮,列表页上方增加、删除及其他自定义按钮app_index.html#应用首页app_list.html#应用列表页base.html#模板基础页面base_site.html#可选择模板主题模板change_form.html#修改页面模板change_form_object_tools.html#修改页面对象工具模板change_list.html#列表模板,即应用默认展示列表模板change_list_object_tools.html#修改列表对象工具页面模板change_list_results.html#修改结果列表color_theme_toggle.html#模板主题颜色选择页面模板date_hierarchy.html#日期层次结构模板delete_confirmation.html#删除确认模板delete_selected_confirmation.html#选择删除确认模板filter.html#过滤器模板index.html#首页模板,即默认登录后首页模板invalid_setup.html#数据库安装错误提示模板login.html#用户登录页nav_sidebar.html#左侧菜单栏模板object_history.html#历史记录模板pagination.html#分页模板popup_response.html#弹出式响应模板prepopulated_fields_js.html#预先填充字段的模板search_form.html#搜索框页面模板submit_line.html#提交

页面内部分标签说明文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/62533.html

{% block title %}{% endblock %}#站点标题{% block stylesheet %}{%%20static "admin/css/base.css" %}{% endblock %}"#基础css路径{% block dark-mode-vars %}  <link rel="stylesheet" href="{%%20static "admin/css/dark_mode.css" %}">  <script src="{%%20static "admin/js/theme.js" %}" defer></script>{% endblock %}#主题静态文件路径{% if not is_popup and is_nav_sidebar_enabled %}{% endif %}#is_popup判断{% block extrastyle %}{% endblock %}#额外css{% block extrahead %}{% endblock %}#额外head设置{% block responsive %}{% endblock %}#请求判断{% block blockbots %}{% endblock %}#搜索引擎优化配置{% if is_popup %}popup {% endif %}{% block bodyclass %}{% endblock %}"#body class设置    {%%20if not is_popup %}    <!-- Header -->    #头部开始    {% block header %}        {% block branding %}{% endblock %}#标签页面        {% block usertools %}        {%%20if has_permission %}            {% block welcome-msg %}            {% endblock %}#欢迎词加注            {% block userlinks %}                {%%20if site_url %}                {%%20endif %}#站点链接                {%%20if user.is_active and user.is_staff %}                    {% url 'django-admindocs-docroot' as docsroot %}                    {%%20if docsroot %}                        #文档链接                    {%%20endif %}                {%%20endif %}                {%%20if user.has_usable_password %}               #修改密码                {%%20endif %}            {% endblock %}#链接        {%%20endif %}#权限判断        {% endblock %}#页头顶部        {% block nav-global %}{% endblock %}#全局顶部导航    {% endblock %}    <!-- END Header -->    {% block nav-breadcrumbs %}        {% block breadcrumbs %}        {% endblock %}    {% endblock %}#面包屑    {%%20endif %}
    {%%20if not is_popup and is_nav_sidebar_enabled %}        {% block nav-sidebar %}          {%%20include "admin/nav_sidebar.html" %}        {% endblock %}    {%%20endif %}#左侧菜单
    {% block messages %}      {%%20if messages %}      {%%20endif %}    {% endblock messages %}#站点消息提醒
    {% block pretitle %}{% endblock %}    {% block content_title %}{%%20if title %}<h1>{{ title }}</h1>{%%20endif %}{% endblock %}    {% block content_subtitle %}{%%20if subtitle %}<h2>{{ subtitle }}</h2>{%%20endif %}{% endblock %}    {% block content %}      {% block object-tools %}{% endblock %}#对象工具    {% endblock %}    {% block sidebar %}{% endblock %}#右侧列表
    <!-- END Content -->    {% block footer %}<div id="footer"></div>{% endblock %}#页脚

掌握了上述代码的逻辑及修改位置,Django admin默认模板的修改就可以得心应上,将网站后台改为你想要的样子。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/62533.html

  • 本站内容整理自互联网,仅提供信息存储空间服务,以方便学习之用。如对文章、图片、字体等版权有疑问,请在下方留言,管理员看到后,将第一时间进行处理。
  • 转载请务必保留本文链接:https://www.cainiaoxueyuan.com/bc/62533.html

Comment

匿名网友 填写信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定