From 87f5d07eededc86f8ce1797fdfca7d4903ee0edc Mon Sep 17 00:00:00 2001 From: Sanyam Khurana <8039608+CuriousLearner@users.noreply.github.com> Date: Fri, 14 Jun 2019 21:50:29 +0530 Subject: Fixed #12952 -- Adjusted admin log change messages to use form labels instead of field names. --- tests/admin_views/admin.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'tests/admin_views/admin.py') diff --git a/tests/admin_views/admin.py b/tests/admin_views/admin.py index 8f0aaf843f..44333e893f 100644 --- a/tests/admin_views/admin.py +++ b/tests/admin_views/admin.py @@ -893,8 +893,27 @@ class CityInlineAdmin(admin.TabularInline): view_on_site = False +class StateAdminForm(forms.ModelForm): + nolabel_form_field = forms.BooleanField(required=False) + + class Meta: + model = State + fields = '__all__' + labels = {"name": "State name (from form's Meta.labels)"} + + @property + def changed_data(self): + data = super().changed_data + if data: + # Add arbitrary name to changed_data to test + # change message construction. + return data + ['not_a_form_field'] + return data + + class StateAdmin(admin.ModelAdmin): inlines = [CityInlineAdmin] + form = StateAdminForm class RestaurantInlineAdmin(admin.TabularInline): -- cgit v1.3