paginate
This commit is contained in:
@@ -11,10 +11,15 @@ def load_user(user_id):
|
|||||||
|
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
def home():
|
def home():
|
||||||
|
page = request.args.get('page', 1, type=int)
|
||||||
|
per_page = 10
|
||||||
property_type = request.args.get('property_type')
|
property_type = request.args.get('property_type')
|
||||||
listings = Listing.query.all()
|
|
||||||
|
query = Listing.query
|
||||||
if property_type:
|
if property_type:
|
||||||
listings = [l for l in listings if l.property_type == property_type]
|
query = query.filter_by(property_type=property_type)
|
||||||
|
|
||||||
|
listings = query.paginate(page=page, per_page=per_page)
|
||||||
return render_template('index.html', listings=listings)
|
return render_template('index.html', listings=listings)
|
||||||
|
|
||||||
@app.route('/login', methods=['GET', 'POST'])
|
@app.route('/login', methods=['GET', 'POST'])
|
||||||
|
|||||||
Reference in New Issue
Block a user