Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Formatting media.datetime #271

nelsonov opened this issue Nov 13, 2017 · 2 comments


None yet
2 participants
Copy link

commented Nov 13, 2017

In the documentation for themes, you mention formatting datetime like this:
{% if media.exif.datetime %}
{{ media.exif.datetime.strftime('%A, %d. %B %Y') }}
{% endif %}

However, media.exif.datetime does not appear to be a Python datetime object. When I attempt this in the colorbox index.html, I get the following error
File "/media/cams/themes/colorbox/templates/index.html", line 44, in template
data-date=", {{ media.exif.datetime.strftime('%c') }}"
jinja2.exceptions.UndefinedError: 'unicode object' has no attribute 'strftime'

Am I missing something?

Thank you.


This comment has been minimized.

Copy link

commented Nov 14, 2017

The documentation is wrong (sorry!), datetime is indeed a formatted string (with strftime('%A, %d. %B %Y')), but there is also a dateobj key with the Python datetime object:
Can you check if it works for you ? (And if you want to fix it, you're welcome 😉 )

nelsonov added a commit to nelsonov/sigal that referenced this issue Nov 26, 2017

Add more media.dateobj values and correct documentation
As discussed in Issue saimn#271

In the documentation media.dateobj was mistakenly called
media.datetime while media.datetime itself is a string.

Added some more media date related values.  To avoid breaking things,
dateobj and datetime remain unchanged.  datetimelocal, datelocal and
timelocal were added.  As their names imply, they contain values
appropriate for the system's LOCALE.

@saimn saimn closed this in 1e96a7c Jan 3, 2018


This comment has been minimized.

Copy link

commented Jan 3, 2018

I added a datetime_format setting in 1e96a7c

@saimn saimn added this to the 1.4 milestone Jan 3, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.