class User(db.Document):
email = db.StringField(required=True)
first_name = db.StringField(max_length=50)
ref = db.ReferenceField('Post')
class Post(db.Document):
title = db.StringField(max_length=120, required=True)
tags = db.ListField(db.StringField(max_length=30))
I have two classes User and Post. I want to access the elements of User class from Post class(ref) using:
User.objects.first().ref.title
Error:
AttributeError: 'NoneType' object has no attribute 'title'
How do I do it? How to access all elements and not just one. Thanks in advance.