Flask Custom Filter Template not working -


i'm attempting add own custom filter templates in flask app i'm writing. goal have display shows "days ago" time posts (similar twitter does).

my views.py file contains following:

import datetime  @app.template_filter('days_ago')  def days_ago(t=datetime.timedelta(0)):     diff = (datetime.datetime.now() - t)     return diff.days  @app.route('/posts/<id>') def view_post(id):     p = models.post.query.get(id)     return render_template('view_post.html',                      post = p) 

and view_post.html template contains:

... <p>{{ post.created_at | days_ago }} days old</p> ... 

i keep running across error:

typeerror: unsupported operand type(s) -: 'datetime.datetime' , 'nonetype' 

i've attempted have parameter t default datetime , timedelta objects, still same error. leads? time in advance!


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -