title: SQLAlchemy Many-To-Many join
body: <p>This is my models:Products and tags have Many-To-Many relationship</p>
  
  <pre><code>products_tags_table=db.Table('products_tags',
                          db.Column('product_id', db.Integer,db.ForeignKey('products.id'), nullable=False),
                          db.Column('tag_id',db.Integer,db.ForeignKey('tag.id'),nullable=False),
                          db.PrimaryKeyConstraint('product_id', 'tag_id')
                          )
  
  class Tag(db.Model):
      __tablename__ = "tags"
      id = db.Column( db.Integer, primary_key = True)
      name = db.Column( db.String(256) )
      description = db.Column( db.Text() )
      background_img_url = db.Column( db.String(256) )
      products =db.relationship('Product',
                                secondary=products_tags_table,
                                backref='product_tags'
                               )  
  
  
  
  
  class Product(db.Model):
      __tablename__ = "products"
      id = db.Column( db.Integer, primary_key = True)
      name = db.Column( db.String(256) )
      tags=db.relationship('ProductTag',
                          secondary=products_tags_table,
                          backref='tag_products'
                          )  
  </code></pre>
  
  <p>When I do the join Tag with Product. I got error:</p>
  
  <p>class 'sqlalchemy.exc.InvalidRequestError': Could not find a FROM clause to join from. Tried joining to , but got: Can't find any foreign key relationships between 'product_tags' and 'products'. </p>
  
  <p>Here are my join code:</p>
  
  <pre><code>avai_tags = Tag.query.join(Product).order_by(ProductTag.name)
  </code></pre>
  
  <p>Am I missing something ?</p>