Django Jet中的自定义徽标 [英] Custom logo in django jet

查看:83
本文介绍了Django Jet中的自定义徽标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在尝试对django管理控制台的外观进行一些自定义,以使其更符合我们的品牌。目前,我们使用django-jet整理管理面板。 django-jet是否可以定制css / html?所有评论都说我应该更改一些html文件,但是我认为这些文件对我的项目是隐藏的,因为django-jet会处理这些文件?如果有人能指出我正确的方向,将不胜感激。

I am currently trying to do some customization to the skin of the django admin panel, to make it more in line with our brand. Currently we use django-jet to spruce up the admin panel. Are custom css/html possible with django-jet? All of the comments say that I should change some html files, but I think those files are hidden from my project because django-jet takes care of them? If anyone could point me in the right direction it would be appreciated.

谢谢

推荐答案

该主题已在 django-jet github页面

我将尝试用我自己的话来改写提供的解决方案

I will simply try to rephrase provided solution with my own words


  1. 创建 your_app / templates / admin / 文件夹(如果不存在)

  2. 在此文件夹下创建 base_site.html 文件

  3. 将以下代码之一复制到此文件并根据您的需要进行自定义

  1. Create your_app/templates/admin/ folder if doesn't exist
  2. Under this folder create base_site.html file
  3. Copy one of the following code to this file and customize based on your needs


简单代码


Simple code

{# Template: your_app/templates/admin/base_site.html #}
{% extends "admin/base_site.html" %}
{% load static i18n %}

{# Setup favicon #}
{% block extrahead %}<link rel="shortcut icon" type="image/png" href="{{MEDIA_URL}}your_logo.png"/>{% endblock %}

{# Setup browser tab label #}
{% block title %}{{ title }} |  {% trans "Your title" %}{% endblock %}

{# Setup branding #}
{% block branding %}
    <h1 id="site-name">
        <a href="{% url 'admin:index' %}">
            {# Your logo here #}
            <img style="background-color: white" src="{{MEDIA_URL}}your_logo.png" alt="Your Company Name" height="50%" width="50%">
            <br><br>
            </span> {% trans "Your Branding" %}
        </a>
    </h1>
{% endblock %}

{% extends "admin/base.html" %}
{% load static i18n %}

{% block title %}{{ title }} | {{ site_title|default:_('Django site admin') }}{% endblock %}

{% block branding %}
    <h1 id="site-name">
        <span class="icon-jet"></span> {% trans "JET DEMO" %}
    </h1>
{% endblock %}

{% block extrastyle %}
    {{ block.super }}
    <link rel="stylesheet" type="text/css" href="{% static "core/css/branding.css" %}" />
    <link rel="stylesheet" type="text/css" href="{% static "core/css/icons/style.css" %}" />
{% endblock %}

{% block nav-global %}
    <a href="https://github.com/geex-arts/django-jet" class="sidebar-link icon">
        <span class="sidebar-link-label">
            <span class="sidebar-link-icon jet-demo-icon-github"></span>
            {% trans 'Visit GitHub page' %}
        </span>
    </a>
    <a href="https://github.com/geex-arts/django-jet-demo" class="sidebar-link icon">
        <span class="sidebar-link-label">
            <span class="sidebar-link-icon jet-demo-icon-github"></span>
            {% trans 'Demo site source code' %}
        </span>
    </a>
{% endblock %}

{% block userlinks %}
    <a href="{% url 'admin:logout' %}">{% trans 'Log out' %}</a>
{% endblock %}

{% block footer %}
    {{ block.super }}
    <!-- Yandex.Metrika counter --><script type="text/javascript"> (function (d, w, c) { (w[c] = w[c] || []).push(function() { try { w.yaCounter32240214 = new Ya.Metrika({ id:32240214, clickmap:true, trackLinks:true, accurateTrackBounce:true, webvisor:true }); } catch(e) { } }); var n = d.getElementsByTagName("script")[0], s = d.createElement("script"), f = function () { n.parentNode.insertBefore(s, n); }; s.type = "text/javascript"; s.async = true; s.src = "https://mc.yandex.ru/metrika/watch.js"; if (w.opera == "[object Opera]") { d.addEventListener("DOMContentLoaded", f, false); } else { f(); } })(document, window, "yandex_metrika_callbacks");</script><noscript><div><img src="https://mc.yandex.ru/watch/32240214" style="position:absolute; left:-9999px;" alt="" /></div></noscript><!-- /Yandex.Metrika counter -->
    <!-- Google Analytics counter -->
    <script>
      (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
      (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
      m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
      })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
      ga('create', 'UA-67280038-1', 'auto');
      ga('send', 'pageview');
    </script>
    <!-- /Google Analytics counter -->
{% endblock %}

这篇关于Django Jet中的自定义徽标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆