title: Flask SQLAlchemy AttributeError: 'NoneType' object has no attribute 'append'
body: <p>I have sucessfully created a User at <code>login</code>, and now I'm querying it:</p>
  
  <pre><code>user = User.query.filter_by(restaurant=session['user']).first()
  </code></pre>
  
  <p><code>user</code> prints: </p>
  
  <pre><code>&lt;ID 1&gt;, &lt;User u'Big Burger'&gt;, &lt;Username u'me'&gt;, &lt;Email me@mac.com'&gt;
  </code></pre>
  
  <p>At this point, I'm trying to create and <code>append</code> objects to <code>user</code>, like so:</p>
  
  <pre><code>burger = Menu('cheeseburger')
  
  db.session.add(burger)
  db.session.commit()
  
  user.menu.append(burger)
  </code></pre>
  
  <p>and I get:</p>
  
  <blockquote>
    <p>AttributeError: 'NoneType' object has no attribute 'append'</p>
  </blockquote>
  
  <p>but how do It get this <code>NoneType</code> traceback if <code>burger</code> prints:</p>
  
  <pre><code>&lt;Items u'cheeseburger'&gt;
  </code></pre>
  
  <p>?</p>
  
  <p><strong>models.py</strong></p>
  
  <pre><code>class User(db.Model):
      __tablename__='user'
      """
      Model for storing user data. 
      """
      id = db.Column(db.Integer, primary_key=True)
      restaurant = db.Column(db.String(50))
      username = db.Column(db.String(80), unique=True)
      email = db.Column(db.String(120), unique=True)
  
      menu = db.relationship("Menu",
                      backref=db.backref('user'), uselist=False)
  
  
      def __init__(self, restaurant, username, email):
          self.restaurant = restaurant
          self.username = username
          self.email = email
  
  
      def __repr__(self):
          return '&lt;ID %r&gt;, &lt;User %r&gt;, &lt;Username %r&gt;, &lt;Email %r&gt;' % (self.id,                                                                      self.restaurant,                                                                      self.username,                                                                      self.email)
  
      @property
      def serialize(self):
         """Return object data in easily serializeable format"""
         return { 'id' : self.id,
                  'mail' : self.email,
                  'restaurant' : self.restaurant,
                  'username' : self.username,
                  'menu' : self.menu }
  
  class Menu(db.Model):
      __tablename__='menu'
      """
      Model for storing menus. 
      """
  
      id = db.Column(db.Integer, primary_key=True)
      items = db.Column(db.String(50))    
      user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
  
      def __init__(self, items):
          self.items = items
  
  
      def __repr__(self):
          return '&lt;items %r&gt;' % (self.items)
  
      @property
      def serialize(self):
         """Return object data in easily serializeable format"""
         return { 'items' : self.items }
  </code></pre>