From de882df442dbebb96169f87e3e85df59cb312f32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 5 Mar 2012 14:47:10 +0100 Subject: [PATCH] Include date in context --- settings.py | 1 + trans/context_processors.py | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/settings.py b/settings.py index ab02a4542..7ab558960 100644 --- a/settings.py +++ b/settings.py @@ -146,6 +146,7 @@ TEMPLATE_CONTEXT_PROCESSORS = ( 'django.contrib.messages.context_processors.messages', 'trans.context_processors.version', 'trans.context_processors.title', + 'trans.context_processors.date', ) # A sample logging configuration. The only tangible logging diff --git a/trans/context_processors.py b/trans/context_processors.py index 1672770d4..2c2eed120 100644 --- a/trans/context_processors.py +++ b/trans/context_processors.py @@ -1,8 +1,16 @@ import trans from django.conf import settings +from datetime import datetime, date def version(request): return {'version': trans.VERSION} def title(request): return {'site_title': settings.SITE_TITLE} + +def date(request): + return { + 'current_date': datetime.utcnow().strftime('%Y-%m-%d'), + 'current_year': datetime.utcnow().strftime('%Y'), + 'current_month': datetime.utcnow().strftime('%m'), + }