Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flask-Admin (python) - Having trouble overriding templates

Tags:

python

flask

I am attempting to utilize Flask-Admin for an administrative interface to my web service.

I have it working, but the theme does not match what the rest of my site uses. The documentation here suggests that it is as simple as overriding the master template, but when I do that I end up with circular reference errors.

I have also tried on individual templates by copying the templates from the install directory to my application structure, but I cannot figure out the path they use. It is like it just defaults to the install directory, even if I have templates of the same name local to my flask app. From the docs: "You can override any used template in your Flask application by creating template with same name and relative path in your main templates directory."... yet I am not able to do that. Does it still expect admin/ in front of the templates?

Does anyone have an example? I basically need to override the bootstrap theme used, but some other customization could be nice. I'm new to flask, and python for that matter, so this may be quite simple...

like image 229
Evan Jensen Avatar asked Jun 17 '13 22:06

Evan Jensen


1 Answers

You will still need to place your templates in the admin sub-folder of templates:

yourapp/
    app.py
    templates/
        master.html  # <-- This will not override admin/master
        admin/
            master.html  # <-- This one, however, will :-)
like image 156
Sean Vieira Avatar answered Sep 20 '22 18:09

Sean Vieira