10

I wanna know how can I change the default font using in django admin interface?

Brgds

Hossein
  • 828
  • 1
  • 9
  • 31

1 Answers1

14
  1. Create a folder name admin in your template directory.
  2. Create a file named base_site.html in there.
  3. Create a css file in your static directory. for example: override.css, where you might put the code for changing font:

     p {
      font-family : "Fira Code"
     }
     h1 {
      font-family: "Fira Code"
     }
    
  4. Now update the base_site.html like following:

    {% extends 'admin/base_site.html' %}
    
    {% load static %}
    
    {% block extrastyle %}{{ block.super }}<link rel="stylesheet" type="text/css" href="{% static 'override.css' %}" />{% endblock %}
    

The override.css will change the fonts of p and h1 across admin site. Modify override.css according to your need. Hope it helps!!

ruddra
  • 50,746
  • 7
  • 78
  • 101
  • I used exactly your code in my base_site.html in my temlate directory but my browser can't find override.css in static directory. – Hossein Nov 05 '18 at 08:00
  • in browser, did any link with `override.css` appeared? BTW which django version are you using? – ruddra Nov 05 '18 at 08:21
  • this error solved, whats the difference between STATIC_ROOT and STATICFILES_DIRS? my django version : 2.0.5 – Hossein Nov 05 '18 at 09:13
  • https://stackoverflow.com/questions/24022558/differences-between-staticfiles-dir-static-root-and-media-root :) – ruddra Nov 05 '18 at 09:20