reading from joined query in flask-sqlalchemy

This query:

opinions = Opinion.query
                    .filter_by(party_id=form.party.data)
                    .filter_by(topic_id=form.topic.data)
                    .join(Topic)
                    .all()

will return a list of Opinion models and since in your relationship in Topic model, you defined it as:

opinions = db.relationship(Opinion, backref='topic')

Then, in your jinja2 template, to access Topic.topic_name, you should do:

<h1>{{ opinion.topic.topic_name }}</h1>