Skip to content

Instantly share code, notes, and snippets.

@jmcelroy5
Created November 10, 2014 23:35
Show Gist options
  • Save jmcelroy5/b27455eeb8ae0c94e46c to your computer and use it in GitHub Desktop.
Save jmcelroy5/b27455eeb8ae0c94e46c to your computer and use it in GitHub Desktop.
Flask function + Jinja template
// Flask function:
@app.route("/")
def home_page():
# Get first 10 bikes from database
bikes = model.session.query(model.Bike).limit(10).all()
return render_template("index.html", bikes=bikes)
// In Jinja template:
{% extends 'base.html' %}
{% block content %}
<div>
{% for bike in bikes %}
<p> Why isn't this block showing?! </p>
<h3> {{ bike.title }} <h3>
<img src="{{ bike.thumb }}">
{% endfor %}
</div>
<br>
<div>
<p> This block IS showing up </p>
<p> map with listing markers will go here<p>
</div>
{% endblock %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment