How to customize Flask Admin templates?
Put your CSS changes in a new CSS file in /static/css/my_flask_admin.css
.
Then override the HTML template. This can be done by creating a file called /templates/admin/master.html
with the following contents:
{% extends admin_base_template %}{% block head_css %} {{ super() }} <link rel="stylesheet" href="{{ url_for('static', filename='css/my_flask_admin.css') }}">{% endblock %}
The extends
and block
calls inherit the original template and hook into the CSS definitions. The super()
call loads the original CSS files. The url_for(...)
call appends your CSS file after those, effectively prioritizing your file over the originals.