Opened 13 years ago

Closed 13 years ago

Last modified 12 years ago

#15218 closed (duplicate)

USE_L10N, USE_I18N and DateTime Validation

Reported by: idle sign Owned by: nobody
Component: contrib.admin Version: 1.3-beta
Severity: Keywords: blocker, regression
Cc: idlesign@… Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Since 1.2.4 and further till SVN the behaviour of DateTime widget seems to be weird.

As it stated in the documentation USE_L10N defaults to False and before 1.2.4 it worked as expected:

  1. put LANGUAGE_CODE = 'ru' and USE_I18N = True into settings;
  2. have contrib.admin in Russian with DateTime widgets using ISO format which differs from Russian native (2011-02-03 vs. 03.02.2011).

Now doing the same with 1.2.4+ I have DateTime widget showing 03.02.2011 so it doesn't validate on save.

The problem is resolved by setting USE_L10N = True, but that makes a little sense.


This ticket could be related to #13621 and #13968.

Change History (6)

comment:1 by idle sign, 13 years ago

Cc: idlesign@… added

comment:2 by Russell Keith-Magee, 13 years ago

Resolution: worksforme
Status: newclosed

Either I'm not understanding this report, or you are misunderstanding what is going on.

USE_I18N only affects translations - i.e., does the admin show "Добавить object" or "Add new object"

USE_L10N affects the formatting of data -- do you use commas or periods to separate decimals, date/time formats etc.

If you have USE_L10N=False, date/times will always be presented in ISO format (i.e., 2011-02-03 16:17:23). I've tested with 1.2.3, 1.2.X and trunk, and this displays and validates as expected.

If you have USE_L10N=True, date/times will be displayed in locale-specific format. For the "ru" locale, this means 03.02.2011. Again, I've tested this with 1.2.3, 1.2.X and trunk, and dates display and validate as expected.

If you don't have USE_L10N defined at all, it defaults to False, which means you don't get localizations.

I can't see anything "weird" the behavior I'm seeing.

If I've misunderstood this report, please reopen with describing what you are seeing, what you would expect to see, and why.

comment:3 by idle sign, 13 years ago

Resolution: worksforme
Status: closedreopened

USE_I18N only affects translations - i.e., does the admin show "Добавить object" or "Add new object"

Not since 1.2.4 or just not for me %)


What you described is exactly how it was till 1.2.4.

Let's try to reproduce this behaviour:

  1. Set LANGUAGE_CODE to 'ru';
  2. Set USE_I18N to True;
  3. Do not define USE_L10N;
  4. Go to admin anywhere where widget for DateTime is used;
  5. Generate current date. It whould be '03.02.2011';
  6. Now save;
  7. Here I've got Validation error since 1.2.4.

Again, only if you put USE_L10N = True date validates fine.

*Before 1.2.4 using the same settings there was ISO '2011-02-03' at step 5.

Last edited 13 years ago by idle sign (previous) (diff)

comment:4 by Russell Keith-Magee, 13 years ago

Component: Internationalizationdjango.contrib.admin
Keywords: blocker regression added
Triage Stage: UnreviewedAccepted

Now I see it. It's not a problem with validation or display of DateTimeFields themselves -- the problem is the widget itself generating a localized widget regardless of the USE_L10N value.

Since this is in 1.2.X, but not in 1.2.3, it's a regression.

comment:5 by Ramiro Morales, 13 years ago

Resolution: duplicate
Status: reopenedclosed

Bisection shows this change of behavior occurred in r13898 (r13903 for 1.2.X between 1.2.3 and 1.2.4). Thus, I'm going to close this as a duplicate of #14824 adding a pointer to it there because I think they describe the same issue.

comment:6 by Jacob, 12 years ago

milestone: 1.3

Milestone 1.3 deleted

Note: See TracTickets for help on using tickets.
Back to Top