1 2 3 4 5 6 7 8 9 10 11 | from django import template
import datetime
register = template.Library ()
@register.simple_tag
def copyright_since(since):
now = datetime.datetime.now().year
if since != now:
return u'© %d—%d' % (int(since), now)
return u'© %d' % now
|
More like this
- Format date range by bmihelac 2 years, 10 months ago
- Template tag to convert number of seconds into mm:ss format by waitinforatrain 2 months, 1 week ago
- DaGood breadcrumbs by drozzy 3 years ago
- Google Analytics Templatetag by rizumu 3 years, 4 months ago
- Send templated email with text | html | optional files by grillermo 4 months, 1 week ago
Comments
© 2008—{% now "Y" %} is even faster?
("stolen" from http://code.djangoproject.com/browser/djangoproject.com/django_website/templates/base.html#L49)
#
I don't see any need for this. I just use: © 2008—{% now "Y" %}
#
You could probably simplify this even further by using a simple_tag. Something like:
#
@David: a filter looks even more simple to me.
#
david_bgk, bartTC: lol, 2009-2009?
#
David: thanks, didn't know about simple_tag
#
David: I've replaced my original snippet code with yours one, works fine
#
Don't you actually have to make changes to the site to (legally) update the copyright label?
#
adamlofts: I think it's just the notice so it doesn't have any legal power
#
This is handy, thanks :)
Improved formatting slightly and fixed some problems with HTML output:
#