A filter that changes a preparsed date from Ultimate Feedparser to a regular datetime instance.
Now you can -for example- pass a feed parsed by feedparser to a template and do this:
{% for item in feed.entries %}
Title: {{ item.title }}<br />
Date: {{ item.updated_parsed|feedparsed|date:"Y-m-d" }}
{% endfor %}
1 2 3 4 5 6 7 8 9 | from django.template import Library
import datetime
register = Library()
def feedparsed(value):
return datetime.datetime(*value[:6])
register.filter(feedparsed)
|
More like this
- Form field with fixed value by roam 4 days, 21 hours ago
- New Snippet! by Antoliny0919 1 week, 4 days ago
- Add Toggle Switch Widget to Django Forms by OgliariNatan 3 months ago
- get_object_or_none by azwdevops 6 months, 3 weeks ago
- Mask sensitive data from logger by agusmakmun 8 months, 2 weeks ago
Comments
Brilliant in its simplicity, and exactly what I came looking for. Works perfectly. Thanks!
#
Please login first before commenting.