Skip to content Skip to sidebar Skip to footer

How To Access The Model Instance From Custom Flask Admin Template

I need to create a pretty complicated view of nested models in my admin page, googled all around the globe (form_edit_rules, edit_template, on_form_prefill), but could not find a w

Solution 1:

The current DB object is passed as the variable model. See flask_admin/model/base.py ~ line 2077:

@expose('/edit/', methods=('GET', 'POST'))
def edit_view(self):

    # code

    model = self.get_one(id)

    # more code

    return self.render(template,
                           model=model,
                           form=form,
                           form_opts=form_opts,
                           return_url=return_url)

Post a Comment for "How To Access The Model Instance From Custom Flask Admin Template"