Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flask-Moment not displaying anything on template

I have a template, named user.html, w/ this line of code:

<p>Member since {{ moment(user.member_since).format('L') }}. Last seen {{ moment(user.last_seen).fromNow() }}.</p>

Which renders the following page:

enter image description here

It looks like it's not rendering anything, yet looking at the source code of that same page:

enter image description here

...I can see my timestamps between tags.

My question is: What is stopping the browser from displaying my timestamp in the browser?


Things to consider:

  • I'm using Flask-Moment==0.5.1 (pulled straight from pip freeze command)
  • I'm pulling the timestamp from a PostgreSQL database (image below)
  • I'm following the Flask Web Development book, by Miguel Grinberg (pulled code straight from there)
  • I've already checked the Flask-Moment github page and the moment.js documentation and found no answer to this question.

Any insight will be greatly appreciated!


Timestamp registry in table

enter image description here

like image 569
Xanagandr Avatar asked Jul 01 '17 19:07

Xanagandr


2 Answers

Found the answer to my question:

The template that needs to use Flask-Moment needs to contain the following lines:

{{ moment.include_jquery() }}
{{ moment.include_moment() }}

This wasn't in the book, yet I found the reference in the The Flask Mega-Tutorial, by the same author:

https://blog.miguelgrinberg.com/post/flask-moment-flask-and-jinja2-integration-with-momentjs

like image 62
Xanagandr Avatar answered Sep 23 '22 23:09

Xanagandr


The times are not displayed as the is style='display: none;' in the tag. This will tell the browser to not display the tag. I don't know where it's comming from, but you should change it to style='display: inline;'.

like image 25
Pim Avatar answered Sep 19 '22 23:09

Pim