我試圖用這樣的燒瓶聯繫的「master.html」模板擴展我的模板:燒瓶管理擴展模板
{% extends 'admin/master.html' %}
{% block body %}
Hello!!!
{% endblock %}
我得到錯誤:
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
for piece in template.split('/'):
UndefinedError: 'admin_base_template' is undefined
這裏如何我初始化燒瓶管理:
admin = Admin(app, name='Spiders')
admin.add_view(AdminView(User, Session, name='Users'))
而且AdminView類:
from flask.ext.admin.contrib.sqlamodel import ModelView
from flask.ext import login
class AdminView(ModelView):
def is_accessible(self):
return login.current_user.is_authenticated()
你能告訴你如何初始化你的管理和模板目錄結構? – alecxe
你在這裏, admin = Admin(app,name ='Spiders') admin.add_view(AdminView(User,Session,name ='Users')) – Sleepwalker
如何定義AdminView? – tbicr