I am new to this and trying to figure out how to make a simple blog with tags. Here are the relevant sections:
Model:
class Post(db.Model):
title = db.StringProperty(required = True)
content = db.TextProperty(required = True)
when = db.DateTimeProperty(auto_now_add = True)
author = db.UserProperty(required = True)
tags = db.ListProperty(db.Category)
WTForm:
class PostForm(wtf.Form):
title = wtf.TextField('Title', validators=[validators.Required()])
content = wtf.TextAreaField('Content', validators=[validators.Required()])
tags = wtf.TextField('Tags', validators=[validators.Required()])
Template:
{% block content %}
<ul>
<h1 id="">List of Posts</h1>
{% for post in posts %}
<li>
{{ post.title } By {{ post.author.nickname() }})<br />
{{ post.content }}<br />
Author {{ post.author }} <br />
Tags {{ post.tags}} <br />
</li>
{% endfor %}
</ul>
{% endblock %}
The problem is that no matter what I enter in the tag field, the template makes an empty list (i.e. '[]') instead of tags. I appreciate your hints to fix this.
source
share