I found an unexpected error report when i tried to click the message icon and then I checked logs message:
Traceback (most recent call last):
rv = self.handle_user_exception(e)
rv = self.dispatch_request()
File "/home/JTPing/microblog/env/lib/python3.10/site-packages/flask_login/utils.py", line 290, in decorated_view
return current_app.ensure_sync(func)(*args, **kwargs)
File "/home/JTPing/microblog/./app/main/routes.py", line 298, in messages
return render_template('messages.html', messages=messages.items, next_url=next_url, prev_url=prev_url)
File "/home/JTPing/microblog/env/lib/python3.10/site-packages/flask/templating.py", line 147, in render_template
rv = template.render(context)
File "/home/JTPing/microblog/env/lib/python3.10/site-packages/jinja2/environment.py", line 1301, in render
File "/home/JTPing/microblog/env/lib/python3.10/site-packages/jinja2/environment.py", line 936, in handle_exception
raise rewrite_traceback_stack(source=source)
{% extends 'bootstrap/base.html' %} <!--You can replace it with other new bootstrap style as you want -->
File "/home/JTPing/microblog/env/lib/python3.10/site-packages/flask_bootstrap/templates/bootstrap/base.html", line 23, in block 'body'
File "/home/JTPing/microblog/app/templates/base.html", line 74, in block 'content'
{% include '_post.html' %}
File "/home/JTPing/microblog/app/templates/_post.html", line 43, in top-level template code
return getattr(obj, attribute)
jinja2.exceptions.UndefinedError: 'app.models.Message object' has no attribute 'comments'
I found an unexpected error report when i tried to click the message icon and then I checked logs message:
It seems that the problem lies in
Message.html:{% for post in messages %} {% inlcude '_post'.html}it seems that the above
includestatement will make all variablepostinpost.htmlinherit from the message. that is to say, the variablepostwas replaced bymessage?