0

i've fallowing this post Customizing the flask admin row actions but i always got jinja2.exceptions.TemplateNotFound: my_list.html. i don't know why.

from app import db, app
from flask_admin import Admin, expose
from flask_admin.contrib.sqla import ModelView
from app.models import User, Post
from flask_admin.model.template import EndpointLinkRowAction, LinkRowAction, TemplateLinkRowAction

class MyView(ModelView):
    list_template = "my_list.html"  # Override the default template
    column_extra_row_actions = [  # Add a new action button
        TemplateLinkRowAction("custom_row_actions.copy_row", "Copy Record"),
    ]
    @expose("/copy", methods=("POST",))
    def copy_view(self):
        pass
        #The method you need to call """

admin = Admin(app, name='microblog', template_mode='bootstrap3')
admin.add_view(MyView(User, db.session))
admin.add_view(ModelView(Post, db.session))

post is working and the admin interface too, but when i push User button in admin i got the message that i already mentioned

this is my directory tree: enter image description here

1 Answers1

1

Looking at your project's directory structure, my_list.html is in the admin directory, which is a sub-directory of the template directory, so it needs to referenced as such:

class MyView(ModelView):
    list_template = "admin/my_list.html"  # Override the default template
    # blah blah
pjcunningham
  • 7,676
  • 1
  • 36
  • 49