flask-admin TypeError: Невозможно скомпилировать узлы без шаблонов - PullRequest
0 голосов
/ 21 февраля 2019

Я слежу за обучением на youtube по работе с flask-admin.Прямо сейчас я просто пытаюсь заставить его работать в rout.py, чтобы увидеть, как он работает (я также пробовал модели, и каждый раз происходит сбой).

Вот мой код

from flask_login import UserMixin
from flask_admin import Admin
from flask_admin.contrib.sqla import ModelView

class User(db.Model, UserMixin):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(20))
admin = Admin(app)
admin.add_view(ModelView(User, db.session))

когда я делаю http://127.0.0.1:5000/admin/ в своем браузере, я получаю сообщение об ошибке

builtins.TypeError
TypeError: Can't compile non template nodes

Последние 3 часа я потратил на то, чтобы выяснить, что происходит, но ничего не происходитчувствую, и я не могу найти нигде подобных проблем.

Traceback

Traceback (most recent call last):
        File "/Users/me/anaconda/lib/python3.6/site-packages/flask/app.py",   line 1997, in __call__
        return self.wsgi_app(environ, start_response)
      File "/Users/me/anaconda/lib/python3.6/site-packages/flask/app.py", line 1985, in wsgi_app
        response = self.handle_exception(e)
      File "/Users/me/anaconda/lib/python3.6/site-packages/flask/app.py", line 1540, in handle_exception
        reraise(exc_type, exc_value, tb)
      File "/Users/me/anaconda/lib/python3.6/site-packages/flask/_compat.py", line 33, in reraise
        raise value
      File "/Users/me/anaconda/lib/python3.6/site-packages/flask/app.py", line 1982, in wsgi_app
        response = self.full_dispatch_request()
      File "/Users/me/anaconda/lib/python3.6/site-packages/flask/app.py", line 1614, in full_dispatch_request
        rv = self.handle_user_exception(e)
      File "/Users/me/anaconda/lib/python3.6/site-packages/flask/app.py", line 1517, in handle_user_exception
        reraise(exc_type, exc_value, tb)
      File "/Users/me/anaconda/lib/python3.6/site-packages/flask/_compat.py", line 33, in reraise
        raise value
      File "/Users/me/anaconda/lib/python3.6/site-packages/flask/app.py", line 1612, in full_dispatch_request
        rv = self.dispatch_request()
      File "/Users/me/anaconda/lib/python3.6/site-packages/flask/app.py", line 1598, in dispatch_request
        return self.view_functions[rule.endpoint](**req.view_args)
      File "/Users/me/anaconda/lib/python3.6/site-packages/flask_admin/base.py", line 69, in inner
        return self._run_view(f, *args, **kwargs)
      File "/Users/me/anaconda/lib/python3.6/site-packages/flask_admin/base.py", line 368, in _run_view
        return fn(self, *args, **kwargs)
      File "/Users/me/anaconda/lib/python3.6/site-packages/flask_admin/base.py", line 452, in index
        return self.render(self._template)
      File "/Users/me/anaconda/lib/python3.6/site-packages/flask_admin/base.py", line 308, in render
        return render_template(template, **kwargs)
      File "/Users/me/anaconda/lib/python3.6/site-packages/flask/templating.py", line 133, in render_template
        return _render(ctx.app.jinja_env.get_or_select_template(template_name_or_list),
      File "/Users/me/anaconda/lib/python3.6/site-packages/jinja2/environment.py", line 869, in get_or_select_template
        return self.get_template(template_name_or_list, parent, globals)
      File "/Users/me/anaconda/lib/python3.6/site-packages/jinja2/environment.py", line 830, in get_template
        return self._load_template(name, self.make_globals(globals))
      File "/Users/me/anaconda/lib/python3.6/site-packages/jinja2/environment.py", line 804, in _load_template
        template = self.loader.load(self, name, globals)
      File "/Users/me/anaconda/lib/python3.6/site-packages/jinja2/loaders.py", line 125, in load
        code = environment.compile(source, name, filename)
      File "/Users/me/anaconda/lib/python3.6/site-packages/jinja2/environment.py", line 581, in compile
        defer_init=defer_init)
      File "/Users/me/anaconda/lib/python3.6/site-packages/jinja2/environment.py", line 543, in _generate
        optimized=self.optimized)
      File "/Users/me/anaconda/lib/python3.6/site-packages/jinja2/compiler.py", line 78, in generate
        raise TypeError('Can\'t compile non template nodes')
    TypeError: Can't compile non template nodes
...