python - Flask-Admin extending templates -


i'm trying extend template 'master.html' template of flask-admin this:

{% extends 'admin/master.html' %} {% block body %}     hello!!! {% endblock %} 

and error:

file "/usr/local/cellar/python/2.7.3/lib/python2.7/site-packages/jinja2-2.6-py2.7.egg/jinja2/environment.py", line 894, in render return self.environment.handle_exception(exc_info, true) file "/users/slowpoke/projects/python/spider/spider/templates/form.html", line 1, in top-level template code {% extends 'admin/master.html' %} file "/usr/local/cellar/python/2.7.3/lib/python2.7/site-packages/flask_admin-1.0.6-py2.7.egg/flask_admin/templates/admin/master.html", line 1, in top-level template code {% extends admin_base_template %} file "/usr/local/cellar/python/2.7.3/lib/python2.7/site-packages/flask-0.9-py2.7.egg/flask/templating.py", line 57, in get_source return loader.get_source(environment, local_name) file "/usr/local/cellar/python/2.7.3/lib/python2.7/site-packages/jinja2-2.6-py2.7.egg/jinja2/loaders.py", line 162, in get_source pieces = split_template_path(template) file "/usr/local/cellar/python/2.7.3/lib/python2.7/site-packages/jinja2-2.6-py2.7.egg/jinja2/loaders.py", line 29, in split_template_path piece in template.split('/'): undefinederror: 'admin_base_template' undefined 

here how i'm initializing flask-admin:

admin = admin(app, name='spiders') admin.add_view(adminview(user, session, name='users')) 

and adminview class:

from flask.ext.admin.contrib.sqlamodel import modelview flask.ext import login class adminview(modelview):     def is_accessible(self):         return login.current_user.is_authenticated() 

look use template outside of flask-admin.

flask_admin.base.baseview have self render function, setup variables. can try setup manualy, not see reason use flask-admin templates outside of flask-admin views.

see bad example:

class myview(baseview):     def __init__(self, *args, **kwargs):         self._default_view = true         super(myview, self).__init__(*args, **kwargs)         self.admin = admin()  @app.route('/form') def form():     return myview().render('form.html') 

Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -