now template tag and predefined format DATE_FORMAT problem

39 views
Skip to first unread message

creecode

unread,
Feb 9, 2011, 10:31:53 AM2/9/11
to Django users
Hello all,

I'm trying to use the now template tag <
http://docs.djangoproject.com/en/1.2/ref/templates/builtins/#now >
with the predefined format DATE_FORMAT and the now tag seems to be
processing the predefined format as a custom format.

I tried...

{% now "DATE_FORMAT" %}

...and get back...

WedAMPSTEPST0FebE_February-0800RFebAMPST

Any thoughts on what I'm doing wrong?

I'm using Django 1.2.x, have USE_I18N and USE_L10N set to True, and
LANGUAGE_CODE is 'en-us' in settings.py.

Toodle-loooooooo
creecode

Daniel Roseman

unread,
Feb 9, 2011, 12:17:58 PM2/9/11
to django...@googlegroups.com
This is very bizarre. Obviously, what's happening is that the string "DATE_FORMAT" is being interpreted as a literal date format, instead of a reference to your locale's actual date string.

What's even more bizarre is that it appears that the documentation is flat-out wrong: the "now" tag does not take the "DATE_FORMAT" parameter, like the "date" filter does. No idea why, or why no-one's noticed it until now. I've confirmed that this is the case in 1.2.4, and the code hasn't changed in trunk. It would be worth raising a ticket for this.
--
DR.

creecode

unread,
Feb 9, 2011, 12:32:45 PM2/9/11
to Django users
Hey Daniel,

I thought things were off somewhere. Just seeing if it was me
first! :-) I looked at the code for Django v1.2.4 and couldn't see
any signs that the now template tag and friends were even checking for
the predefined formats.

Fred Chevitarese

unread,
Feb 9, 2011, 1:02:51 PM2/9/11
to django...@googlegroups.com
I guess :P


"
O relógio da vida recebe corda apenas uma vez.
Ninguém tem o poder de decidir quando os ponteiros pararão, se mais cedo ou se mais tarde.
O presente é o único tempo que você possui.
Viva, ame e trabalhe com vontade.
Não ponha nenhuma esperança no tempo, pois o relógio pode parar a qualquer momento.
"

Fred Chevitarese - GNU/Linux





2011/2/9 Fred Chevitarese <fchevi...@gmail.com>
I guess you are making an mistake. 
It have to be something like this: {% now "jS F Y H:i" %}

You can take a look at the table with the custom datefilters: 


;)

Hope it help! 





"
O relógio da vida recebe corda apenas uma vez.
Ninguém tem o poder de decidir quando os ponteiros pararão, se mais cedo ou se mais tarde.
O presente é o único tempo que você possui.
Viva, ame e trabalhe com vontade.
Não ponha nenhuma esperança no tempo, pois o relógio pode parar a qualquer momento.
"

Fred Chevitarese - GNU/Linux





2011/2/9 creecode <cree...@gmail.com>


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.



creecode

unread,
Feb 9, 2011, 1:11:54 PM2/9/11
to Django users
Hello Fred,

On Feb 9, 10:02 am, Fred Chevitarese <fchevitar...@gmail.com> wrote:

> I guess :P

> > I guess you are making an mistake.
> > It have to be something like this: {% now "jS F Y H:i" %}
>
> > You can take a look at the table with the custom datefilters:
>
> >http://docs.djangoproject.com/en/1.2/ref/templates/builtins/#date

Thank you. I am aware of how to use the custom format. What I am
trying to do is use the predefined formats DATE_FORMAT,
DATETIME_FORMAT, SHORT_DATE_FORMAT or SHORT_DATETIME_FORMAT as
specifically mentioned in the docs for the now template tag <
http://docs.djangoproject.com/en/dev/ref/templates/builtins/#now >.

Toodle-loooooooo..........
creecode

Fred Chevitarese

unread,
Feb 9, 2011, 1:02:02 PM2/9/11
to django...@googlegroups.com
I guess you are making an mistake. 
It have to be something like this: {% now "jS F Y H:i" %}

You can take a look at the table with the custom datefilters: 


;)

Hope it help! 





"
O relógio da vida recebe corda apenas uma vez.
Ninguém tem o poder de decidir quando os ponteiros pararão, se mais cedo ou se mais tarde.
O presente é o único tempo que você possui.
Viva, ame e trabalhe com vontade.
Não ponha nenhuma esperança no tempo, pois o relógio pode parar a qualquer momento.
"

Fred Chevitarese - GNU/Linux





2011/2/9 creecode <cree...@gmail.com>
Hello all,

creecode

unread,
Feb 10, 2011, 11:04:14 AM2/10/11
to Django users
On Feb 9, 9:17 am, Daniel Roseman <dan...@roseman.org.uk> wrote:

It would be worth raising a ticket for this.

Done! < http://code.djangoproject.com/ticket/15267 >.

Toodle-loooooooo..........
creecode

Daniel Roseman

unread,
Feb 10, 2011, 11:36:44 AM2/10/11
to django...@googlegroups.com
Er... blush... I had a go at this myself last night, and have already raised a ticket. I'll mark yours as a duplicate (our fixes were pretty much the same). Sorry about that.
--
DR.

creecode

unread,
Feb 10, 2011, 11:42:00 AM2/10/11
to Django users
Hey Daniel,

On Feb 10, 8:36 am, Daniel Roseman <dan...@roseman.org.uk> wrote:

> Er... blush... I had a go at this myself last night, and have already raised
> a ticket. I'll mark yours as a duplicate (our fixes were pretty much the
> same). Sorry about that.

No problem. As long as it is fixed! :-)

Toodle-loooooooooo..........
creecode
Reply all
Reply to author
Forward
0 new messages