------------ matching function: if footwear_type: query.options(joinedload('vendor')) query = query.filter_by(Footwear.product_type==footwear_type) return query ----------- view: return render_template("searchresult.html", result=result, query=query) ------------- model product: class Footwear(Base): __tablename__ = "footwear" id = db.Column(db.Integer, db.Sequence('footwear_id_seq'), primary_key=True) vendor_product_id = db.Column(db.String) vendor_product_id_hash = db.Column(db.String) vendor = db.Column(db.String, db.ForeignKey('vendor.id')) product_name = db.Column(db.String) size_eu = db.Column(db.Numeric(3, 1)) mm_forefoot_height = db.Column(db.Integer, nullable=True) mm_instep_height = db.Column(db.Integer, nullable=True) mm_foot_length = db.Column(db.Integer, nullable=True) mm_forefoot_width = db.Column(db.Integer, nullable=True) mm_heel_width = db.Column(db.Integer, nullable=True) product_image_url = db.Column(db.String) description_en = db.Column(db.Text, nullable=False) description_de = db.Column(db.Text, nullable=True) description_da = db.Column(db.Text, nullable=True) footwear_type = db.Column(db.String, db.ForeignKey('footwear_type.id')) # Valid values are: M=male, F=Female, U=Unisex sex_enums = ('M','F','U') sex = db.Column(db.Enum(*sex_enums, name="sex_enum"), nullable=False) # Valid values are: A=Adult, C=Children age_group_enums = ('A','C') age_group = db.Column(db.Enum(*age_group_enums, name="age_group_enum"), nullable=False) product_url = db.Column(db.String) date_created = db.Column(db.DateTime, default=datetime.datetime.utcnow) def __repr__(self): return "" % ( self.id, self.vendor, self.product_name, self.vendor_product_id, self.size_eu, self.mm_forefoot_height, self.mm_instep_height, self.mm_foot_length, self.mm_forefoot_width, self.mm_heel_width ) ------------- model vendor: #!/usr/bin/env python #encoding=utf8 """Vendor model""" from flask_sqlalchemy import SQLAlchemy from model.meta import Base, db class Vendor(Base): __tablename__ = "vendor" id = db.Column(db.String, primary_key=True) name = db.Column(db.String) data_url = db.Column(db.String) data_format = db.Column(db.String) website_url = db.Column(db.String) contact_email = db.Column(db.String) active = db.Column(db.Boolean, default=True) footwear = db.relationship('Footwear', backref=db.backref('footwearvendor')) def __repr__(self): return "" % (self.id, self.name, self.active) ------------ template: {% extends "base.html" %} {% block content %}

{{ gettext("Matchende fodtøj") }}

{{ gettext("Nedenfor vises det fodtøj som matcher dine indtastning") }}
Query:
{% for q in query %} {{ q }}={{ query[q] }}
{% endfor %}
{% if not result.count %} {{ gettext("Vi kunne desværre ikke finde noget fodtøj der matcher din indtastning. Prøv evt. igen senere.") }} {% endif %} {% for footwear in result %} {% endfor %}
{% endblock %}