[Django] #27296: Can't use custom formats with new language-independent LogEntry's messages in Django 1.10

26 views
Skip to first unread message

Django

unread,
Sep 29, 2016, 10:17:58 AM9/29/16
to django-...@googlegroups.com
#27296: Can't use custom formats with new language-independent LogEntry's messages
in Django 1.10
--------------------------------+--------------------
Reporter: Ivan Tsouvarev | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.10
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------+--------------------
Say, you have some model, which `__str__` uses
`django.utils.formats.date_format` with custom format string.

`settings.FORMAT_MODULE_PATH` contains module, in which this string is
defined.

So, when you create object of this model via admin interface, the
following things happen:
1. Django calls `construct_change_message` to create LogEntry, which is
decorated with `@translation_override(None)`, which will deactivate
current language
2. To write object representation with custom format in change message,
`django.utils.formats.get_format` will be called
3. `get_format` will try to find custom format, but it can't be done when
active language is None, so original string will be returned as-is
4. `django.utils.dateformat.format` will interpret custom format string
literally, which may not fail with exception, but will be totally wrong
anyway

--
Ticket URL: <https://code.djangoproject.com/ticket/27296>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Sep 29, 2016, 10:35:21 AM9/29/16
to django-...@googlegroups.com
#27296: Can't use custom formats with new language-independent LogEntry's messages
in Django 1.10
--------------------------------+--------------------------------------

Reporter: Ivan Tsouvarev | Owner: nobody
Type: Uncategorized | Status: new
Component: contrib.admin | Version: 1.10
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
--------------------------------+--------------------------------------
Changes (by Tim Graham):

* needs_better_patch: => 0
* component: Uncategorized => contrib.admin
* needs_tests: => 0
* needs_docs: => 0


Comment:

Do you have any suggestions about how to fix that?

--
Ticket URL: <https://code.djangoproject.com/ticket/27296#comment:1>

Django

unread,
Sep 29, 2016, 10:53:50 AM9/29/16
to django-...@googlegroups.com
#27296: Can't use custom formats with new language-independent LogEntry's messages
in Django 1.10
--------------------------------+--------------------------------------

Reporter: Ivan Tsouvarev | Owner: nobody
Type: Uncategorized | Status: new
Component: contrib.admin | Version: 1.10
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
--------------------------------+--------------------------------------

Comment (by Ivan Tsouvarev):

Hard to say. May be there is a way to avoid translation without
deactivating current language?

--
Ticket URL: <https://code.djangoproject.com/ticket/27296#comment:2>

Django

unread,
Sep 29, 2016, 11:35:31 AM9/29/16
to django-...@googlegroups.com
#27296: Can't use custom formats with new language-independent LogEntry's messages
in Django 1.10
--------------------------------+--------------------------------------

Reporter: Ivan Tsouvarev | Owner: nobody
Type: Uncategorized | Status: new
Component: contrib.admin | Version: 1.10
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
--------------------------------+--------------------------------------

Comment (by Claude Paroz):

I don't see a proper solution yet, apart from providing some default
yourself by comparing the `get_format` return value.

--
Ticket URL: <https://code.djangoproject.com/ticket/27296#comment:3>

Django

unread,
Oct 1, 2016, 8:55:48 AM10/1/16
to django-...@googlegroups.com
#27296: Can't use custom formats with new language-independent LogEntry's messages
in Django 1.10
--------------------------------+--------------------------------------

Reporter: Ivan Tsouvarev | Owner: nobody
Type: New feature | Status: closed
Component: contrib.admin | Version: 1.10
Severity: Normal | Resolution: needsinfo
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
--------------------------------+--------------------------------------
Changes (by Tim Graham):

* status: new => closed
* type: Uncategorized => New feature
* resolution: => needsinfo


Comment:

Feel free to reopen if someone thinks of a proposal of how Django could
facilitate this use case.

--
Ticket URL: <https://code.djangoproject.com/ticket/27296#comment:4>

Reply all
Reply to author
Forward
0 new messages