Closed michaelmiscanuk closed 3 years ago
This is not a problem with the application. The code uses post.author.avatar()
to get the avatar for the author of the given post. Your database has a blog post that has no author set, and for that reason you get this crash. If you set the author for all blog posts that are currently set to None
author this problem will go away.
Hi, ok, I might have a little confusion here. I used the post generation from the book and now i have all columns filled. I am not sure if by "author" you mean column author_id - and those are all filled:
as you can see, it is sorted and there is no NULL. So I am not sure this is it. Thank you.
Are all those author IDs valid? Do you have authors created for those IDs?
This is actually easy to figure out. You can just loop through your posts in Python and find the one(s) for which post.author
is None
. Looking at it from the database is okay I guess, but it is not directly what your code is seeing.
Yep. You were totally right. Because I created some users before generating, then deleted some, then generated, I had users starting from ID 4 to 104, but posts started from id 1 to 100. So I missed users 1, 2, 3. Thank you for helping me debug this.
Great. Glad you figured it out.
Hi,
somewhere on version, 11.d flasky got broken with traceback below.
I discovered that it is on this line in _posts.html:
<img class="img-rounded profile-thumbnail" src="{{ post.author.gravatar(size=40) }}">
to be specific in calling function gravatar. My thought was that there is some problem with post.author being None.
I wasn't able to fix it, only to remove the src attribute - to make it work, but now all posts have no icon.
Can you help, please?
Thanks.