Skip to content

Commit

Permalink
Fixed #30758 Moved changed_data evaluation only in case of updating
Browse files Browse the repository at this point in the history
  • Loading branch information
nasirhjafri committed Sep 8, 2019
1 parent 25706d7 commit d22ea18
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions django/contrib/admin/utils.py
Expand Up @@ -489,20 +489,20 @@ def construct_change_message(form, formsets, add):
Translations are deactivated so that strings are stored untranslated.
Translation happens later on LogEntry access.
"""
# Evaluating `form.changed_data` prior to disabling translations is required
# to avoid fields affected by localization from being included incorrectly,
# e.g. where date formats differ such as MM/DD/YYYY vs DD/MM/YYYY.
changed_data = form.changed_data
with translation_override(None):
# Deactivate translations while fetching verbose_name for form
# field labels and using `field_name`, if verbose_name is not provided.
# Translations will happen later on LogEntry access.
changed_field_labels = _get_changed_field_labels_from_form(form, changed_data)

change_message = []
if add:
change_message.append({'added': {}})
elif form.changed_data:
# Evaluating `form.changed_data` prior to disabling translations is required
# to avoid fields affected by localization from being included incorrectly,
# e.g. where date formats differ such as MM/DD/YYYY vs DD/MM/YYYY.
changed_data = form.changed_data
with translation_override(None):
# Deactivate translations while fetching verbose_name for form
# field labels and using `field_name`, if verbose_name is not provided.
# Translations will happen later on LogEntry access.
changed_field_labels = _get_changed_field_labels_from_form(form, changed_data)

change_message.append({'changed': {'fields': changed_field_labels}})
if formsets:
with translation_override(None):
Expand Down

0 comments on commit d22ea18

Please sign in to comment.