Custom edit/list/view templates are getting improperly rendered HTML
See original GitHub issueSupplying a custom template like:
{% extends 'admin/model/create.html' %}
{% block body %}
{{ super() }}
{% endblock %}
and then passing these templates in the ModelView subclass like:
class RosterView(ModelView):
list_template = 'web/roster_list.html.jinja'
create_template = 'web/roster_create.html.jinja'
edit_template = 'web/roster_edit.html.jinja'
column_list = ['name', 'player_name', 'factions', 'entries', 'users', 'points']
column_editable_list = ['name', 'player_name', 'factions', 'entries', 'users']
The HTML doesn’t get properly rendered, the resulting source looks like:
<!DOCTYPE html>
<html>
<head>
<title>Roster - Roster - Admin</title>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<link href="/admin/static/bootstrap/bootstrap2/swatch/default/bootstrap.min.css?v=2.3.2" rel="stylesheet">
<link href="/admin/static/bootstrap/bootstrap2/css/bootstrap-responsive.css?v=2.3.2" rel="stylesheet">
<link href="/admin/static/admin/css/bootstrap2/admin.css?v=1.1.1" rel="stylesheet">
<style>
body {
padding-top: 4px;
}
</style>
<link href="/admin/static/vendor/select2/select2.css?v=3.5.2" rel="stylesheet">
<link href="/admin/static/vendor/bootstrap-daterangepicker/daterangepicker-bs2.css?v=1.3.22" rel="stylesheet">
<link href="/admin/static/vendor/x-editable/css/bootstrap2-editable.css?v=1.5.1.1" rel="stylesheet">
</head>
<body>
<div class="container">
<div class="navbar">
<div class="navbar-inner">
<a class="brand" href="/admin">Admin</a>
<ul class="nav">
<li>
<a href="/admin/">Home</a>
</li>
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="javascript:void(0)">
Pieces<b class="caret"></b></a>
<ul class="dropdown-menu">
<li>
<a href="/admin/figure/">
Figure</a>
</li>
<li>
<a href="/admin/wargear/">
Wargear</a>
</li>
</ul>
</li>
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="javascript:void(0)">
Metadata<b class="caret"></b></a>
<ul class="dropdown-menu">
<li>
<a href="/admin/keyword/">
Keyword</a>
</li>
<li>
<a href="/admin/faction/">
Faction</a>
</li>
</ul>
</li>
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="javascript:void(0)">
Rules<b class="caret"></b></a>
<ul class="dropdown-menu">
<li>
<a href="/admin/ability/">
Ability</a>
</li>
<li>
<a href="/admin/specialization/">
Specialization</a>
</li>
<li>
<a href="/admin/tactic/">
Tactic</a>
</li>
</ul>
</li>
<li class="active dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="javascript:void(0)">
Roster<b class="caret"></b></a>
<ul class="dropdown-menu">
<li class="active">
<a href="/admin/roster/">
Roster</a>
</li>
<li>
<a href="/admin/rosterentry/">
Roster Entry</a>
</li>
</ul>
</li>
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="javascript:void(0)">
User<b class="caret"></b></a>
<ul class="dropdown-menu">
<li>
<a href="/admin/user/">
User</a>
</li>
<li>
<a href="/admin/role/">
Role</a>
</li>
</ul>
</li>
</ul>
<ul class="nav pull-right">
</ul>
</div>
</div>
<ul class="nav nav-tabs actions-nav">
<li class="active">
<a href="javascript:void(0)">List</a>
</li>
<li>
<a href="/admin/roster/new/?url=%2Fadmin%2Froster%2F" title="Create New Record">Create</a></li>
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="javascript:void(0)">With selected<b class="caret"></b></a>
<ul class="dropdown-menu">
<li>
<a href="javascript:void(0)" onclick="return modelActions.execute('delete');">Delete</a>
</li>
</ul>
</li>
</ul>
<div id="no-more-tables">
<table class="table table-striped table-bordered table-hover model-list cf">
<thead class="cf">
<tr>
<th class="list-checkbox-column">
<input type="checkbox" name="rowtoggle" class="action-rowtoggle" title="Select all records" />
</th>
<th class="span1"> </th>
<th class="column-header col-name">
<a href="/admin/roster/?sort=0" title="Sort by Name">Name</a>
</th>
<th class="column-header col-player_name">
<a href="/admin/roster/?sort=1" title="Sort by Player Name">Player Name</a>
</th>
<th class="column-header col-factions">
Factions
</th>
<th class="column-header col-entries">
Entries
</th>
<th class="column-header col-users">
Users
</th>
<th class="column-header col-points">
Points
</th>
</tr>
</thead>
<tr>
<td colspan="999">
<div class="text-center">
There are no items in the table.
</div>
</td>
</tr>
</table>
</div>
<form id="action_form" action="/admin/roster/action/" method="POST" style="display: none">
<input id="url" name="url" type="hidden" value="/admin/roster/">
<input id="action" name="action" type="hidden" value="">
</form>
</div>
<script src="/admin/static/vendor/jquery.min.js?v=3.3.1" type="text/javascript"></script>
<script src="/admin/static/bootstrap/bootstrap2/js/bootstrap.min.js?v=2.3.2" type="text/javascript"></script>
<script src="/admin/static/vendor/moment.min.js?v=2.22.2" type="text/javascript"></script>
<script src="/admin/static/vendor/select2/select2.min.js?v=3.5.2" type="text/javascript"></script>
<script src="/admin/static/vendor/bootstrap-daterangepicker/daterangepicker.js?v=1.3.22"></script>
<script src="/admin/static/vendor/x-editable/js/bootstrap2-editable.min.js?v=1.5.1.1"></script>
<script src="/admin/static/admin/js/form.js?v=1.0.1"></script>
<script src="/admin/static/admin/js/filters.js?v=1.0.0"></script>
<div id="actions-confirmation-data" style="display:none;">{"delete": "Are you sure you want to delete selected records?"}</div>
<div id="message-data" style="display:none;">"Please select at least one record."</div>
<script src="/admin/static/admin/js/actions.js?v=1.0.0"></script>
</body>
</html>
And the appearance is like:

I’m just following the example from the documentation here: https://flask-admin.readthedocs.io/en/latest/introduction/#extending-the-built-in-templates
Is there something missing to make this template customization work? When I don’t try to override defaults everything appears to work correctly
Issue Analytics
- State:
- Created 4 years ago
- Comments:5
Top Results From Across the Web
Django displays incorrect template - python - Stack Overflow
When Clients want to see their calculations, correct information is displayed but the template rendered is for Administrators rather than for ...
Read more >Django Tutorial Part 6: Generic list and detail views
In this tutorial we're going to complete the first version of the ... and then call render() to pass the list to a...
Read more >NetSuite Applications Suite - Oracle Help Center
Create a View to Render a Registered Page Type · Register a Page Type · Register a Template · Supported Page Types ·...
Read more >ListView - Android Developers
To display a more custom view for each item in your dataset, implement a ListAdapter. For example, extend BaseAdapter and create and configure...
Read more >Custom Render Textures - Unity - Manual
Writing a shader for a Custom Render Texture ; _CustomRenderTexture3DSlice, float, Index of the current 3D slice being processed. This only applies to...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Appreciate this has been a while, but may be helpful for those searching for this problem. I had a similar issue although it was only the top navbar links that were escaped out and displaying incorrectly for me.
I was able to resolve by changing my custom template extension from
.html.j2
to.html
. I noticed your custom template also had the double extension.html.jinja
. Not sure why the admin templating system is being picky about the file extension?Just had the same issue here using templates ending with
.html.jinja
.