title: Query One to Many Relationship SQLAlchemy
body: <p>I am trying to query the users based upon their skills from these tables.</p>
  
  <pre><code>class User(UserMixin, db.Model):
      __tablename__ = 'users'
  
      id = db.Column(db.Integer, primary_key=True)
      email = db.Column(db.String(64), unique=True, index=True)
      username = db.Column(db.String(64), unique=True, index=True)
      skills = db.relationship('Skill', backref='author', lazy='dynamic')
  </code></pre>
  
  <hr>
  
  <pre><code>class Skill(db.Model):
      __tablename__ = 'skills'
  
      id = db.Column(db.Integer, primary_key=True)
      skill = db.Column(db.String(64), index=True)
      author_id = db.Column(db.Integer, db.ForeignKey('users.id'))
  </code></pre>
  
  <p>i tried this in <strong>User</strong> table and got this error.</p>
  
  <pre><code>@classmethod
  def users_by_skill(cls, skill):
      return User.query.join(Skill).filter(skill.skill).all()
  </code></pre>
  
  <hr>
  
  <pre><code>AttributeError: 'str' object has no attribute 'skill'
  </code></pre>
  
  <p>Where i am missing badly?</p>