title: Error flask-sqlalchemy NameError: global name 'joinedload' is not defined
body: <p>I'm trying to use a sqlalchemy loading strategy to speed up my queries. After reading <a href="http://www.tracelytics.com/blog/advanced-sqlalchemy-performance-concerns/">this</a> I realized that I was making the mistake of looping through the records in my template. The only problem is that i get this error: </p>
  
  <blockquote>
    <p>NameError: global name 'joinedload' is not defined.</p>
  </blockquote>
  
  <p>Is this happening because I'm using flask-sqlalchemy or em I forgetting to import something? </p>
  
  <p>Models.py: </p>
  
  <pre><code>inspection_violations = db.Table('inspection_violations',
  db.Column('violation_id', db.Integer, db.ForeignKey('violations.violation_number')),
  db.Column('inspection_id', db.Integer, db.ForeignKey('inspection.inspection_id')), )
  
  class Inspection(db.Model):
      inspection_id = db.Column(db.Integer, primary_key=True)
      violations = db.relationship('Violations', secondary=inspection_violations, backref=db.backref('inspection', lazy='dinamic'))
      facility_id = db.Column(db.String(100), db.ForeignKey('facilities.branch_name'))
  
  class Violations(db.Model):
      violation_number = db.Column(db.Integer, primary_key=True)
      details  = db.Column(db.Text)
  </code></pre>
  
  <p>Violation Blueprint:</p>
  
  <pre><code>@violations_blueprint.route('/violations/&lt;int:violation_number&gt;')
  def show_single_violation(violation_number):
      violation = Violations.query.options(joinedload('inspection')).get(violation_number)
      return render_template('violations/single-violation.html' ,violation=violation)
  </code></pre>
  
  <p>Template: </p>
  
  <pre><code>{% for inspection in violation.inspection %} 
    &lt;p&gt;&lt;a href="{{ url_for('inspection_blueprint.show_inspection', id=inspection.inspection_id) }}"&gt;    {{ inspection.facilities.branch_name }}&lt;/a&gt;&lt;/p&gt;
  {% endfor %}
  </code></pre>
  
  <p>To give some context to my models I have a inspection record. Every inspection has one or more violations. And every violation has many inspections</p>