#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:
- put LANGUAGE_CODE = 'ru' and USE_I18N = True into settings;
- 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.
Change History (6)
comment:1 by , 14 years ago
Cc: | added |
---|
comment:2 by , 14 years ago
Resolution: | → worksforme |
---|---|
Status: | new → closed |
comment:3 by , 14 years ago
Resolution: | worksforme |
---|---|
Status: | closed → reopened |
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:
- Set LANGUAGE_CODE to 'ru';
- Set USE_I18N to True;
- Do not define USE_L10N;
- Go to admin anywhere where widget for DateTime is used;
- Generate current date. It whould be '03.02.2011';
- Now save;
- 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.
comment:4 by , 14 years ago
Component: | Internationalization → django.contrib.admin |
---|---|
Keywords: | blocker regression added |
Triage Stage: | Unreviewed → Accepted |
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 , 14 years ago
Resolution: | → duplicate |
---|---|
Status: | reopened → closed |
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.