Using DATE_FORMAT in django 1.2

已查看 146 次
跳至第一个未读帖子

Tomas Zulberti

未读,
2010年6月5日 18:17:122010/6/5
收件人 Django users
Hi. I have the following values in the settings.py:
USE_L10N = True
DATETIME_FORMAT = '%d/%m/%Y'

When the date is printed it prints: "Nov. 24, 1983". The date is:
datetime.date(1983, 11, 24).
As far as I was able to follow the code, in the django/utils/
formats.py, the it uses the the get_format function because I have in
the settings USE_L10N. So it will use get_format will use
format_module of my sistem (english) to format the date.

The problem is that if I don't use USE_L10N to True, the function
localize() in the same module will return a datetime.date() object
insted of using the settings DATE_FORMAT value. After that the method,
force_unicode will be used, which it doesn't use the settings at all
(it does str(datetime.date())).

So my question is: is this a bug, or I am doing something wrong (I am
sure I might be doing something grong but I don't know where).

Thanks in advance,
Tomas Zulberti

pd: Sorry for my bad English.

Karen Tracey

未读,
2010年6月5日 19:11:082010/6/5
收件人 django...@googlegroups.com
On Sat, Jun 5, 2010 at 6:17 PM, Tomas Zulberti <tzul...@gmail.com> wrote:
So my question is: is this a bug, or I am doing something wrong (I am
sure I might be doing something grong but I don't know where).

I ran into the same behavior this afternoon. I think it is a bug: http://code.djangoproject.com/ticket/13702

Karen
--
http://tracey.org/kmt/

Tomas Zulberti

未读,
2010年6月6日 09:57:422010/6/6
收件人 Django users


On Jun 5, 8:11 pm, Karen Tracey <kmtra...@gmail.com> wrote:
> On Sat, Jun 5, 2010 at 6:17 PM, Tomas Zulberti <tzulbe...@gmail.com> wrote:
> > So my question is: is this a bug, or I am doing something wrong (I am
> > sure I might be doing something grong but I don't know where).
>
> I ran into the same behavior this afternoon. I think it is a bug:http://code.djangoproject.com/ticket/13702
>
> Karen
> --http://tracey.org/kmt/

Thanks for all your help.

Karen Tracey

未读,
2010年6月6日 10:07:332010/6/6
收件人 django...@googlegroups.com
On Sun, Jun 6, 2010 at 9:57 AM, Tomas Zulberti <tzul...@gmail.com> wrote:
On Jun 5, 8:11 pm, Karen Tracey <kmtra...@gmail.com> wrote:
> On Sat, Jun 5, 2010 at 6:17 PM, Tomas Zulberti <tzulbe...@gmail.com> wrote:
> > So my question is: is this a bug, or I am doing something wrong (I am
> > sure I might be doing something grong but I don't know where).
>
> I ran into the same behavior this afternoon. I think it is a bug:http://code.djangoproject.com/ticket/13702
>

Thanks for all your help.

By the way what I did to work around the problem in my own project was leave USE_L10N=True in settings.py and create a custom formats file for the locale I'm using, as described here:

http://docs.djangoproject.com/en/dev/topics/i18n/localization/#creating-custom-format-files
 
Karen
--
http://tracey.org/kmt/

回复全部
回复作者
转发
0 个新帖子