flask-admin
flask-admin copied to clipboard
How to use the flask-admin template outside of the admin views
I want my login and register pages to have the same layout as the admin pages, but I always get the infamous errors showing that 'admin_base_template' is undefined.
How can I accomplish this (DRY)?
You have to extends from admin/base.html
. In example, for Flask-Security you can do this:
{% extends 'admin/base.html' %}
{% block access_control %}
{% if current_user.is_authenticated %}
<div class="navbar-text btn-group pull-right">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
<i class="glyphicon glyphicon-user"></i>
{% if current_user.name -%}
{{ current_user.name }}
{% else -%}
{{ current_user.email }}
{%- endif %}<span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li><a href="{{ url_for_security('change_password') }}">Change password</a></li>
<li><a href="{{ url_for_security('logout') }}">Log out</a></li>
</ul>
</div>
{% endif %}
{% endblock %}
and your template will have same layout.
I'm getting the same error. What was your solution?
It's been a while. I think that overwriting admin/templates/admin/base.html did it.