Forums

flask-admin templates...where are they

https://flask-admin.readthedocs.io/en/v1.0.7/templates/#customizing-templates

The docs always refer to: All Flask-Admin templates should derive from admin/master.html.

where exactly does that file live, or do I need to create it myself? I was assuming it would be installed by the pip command somewhere, but I can't see it anywhere in my directory structure.

Second question, can you use flask-admin without sql-alchemy? I'm kind of keen to just use pyodbc which I already have working after much hair pulling with Azure sql.

Thanks for any insight, on the steep early part of the python learning curve having stayed in ColdFusion land for years. Cheers Dale

Regarding the Flask-admin template, it will be installed in the same place as the code for that module itself. For example, if you were using a Python 3.6 virtualenv called foo, it would be somewhere under

~/.virtualenvs/foo/lib/python3.6/site-packages/flask_admin/templates

If you're using the site-wide install of Flask-admin, it will be somewhere like /usr/lib/python3.6/site-packages/flask_admin/templates for Python 3.6.

In general, if you're just using the default admin design, you won't need to access it. The idea is that you make your templates inherit from it, rather than that you copy it and edit it yourself. Just put

{% extends "admin/master.html" %}

...at the top of each of your custom admin templates. The Jinja docs linked from the page you mention are pretty good; check out the "Template Inheritance" section.

I don't know about the pyodbc question, though -- I believe that the only built-in database support is for SQLAlchemy and for MongoDB. On the other hand, you can use SQLAlchemy as a wrapper around pyodbc, so perhaps you could structure things so that most of your own code used pyodbc directly but the admin stuff used SQLAlchemy.

Thanks for the reply giles, much appreciated!

No problem, glad to help!