From b33f10d8cc5037f49d5f9c462c510f0fcf11bcf5 Mon Sep 17 00:00:00 2001 From: Hasan Ramezani Date: Mon, 23 Apr 2018 06:48:46 +0430 Subject: Refs #29131 -- Made ArrayField error messages index from 1 instead of 0. --- django/contrib/postgres/fields/array.py | 4 ++-- django/contrib/postgres/forms/array.py | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'django') diff --git a/django/contrib/postgres/fields/array.py b/django/contrib/postgres/fields/array.py index bf5666e2da..d2c1743861 100644 --- a/django/contrib/postgres/fields/array.py +++ b/django/contrib/postgres/fields/array.py @@ -160,7 +160,7 @@ class ArrayField(CheckFieldDefaultMixin, Field): error, prefix=self.error_messages['item_invalid'], code='item_invalid', - params={'nth': index}, + params={'nth': index + 1}, ) if isinstance(self.base_field, ArrayField): if len({len(i) for i in value}) > 1: @@ -179,7 +179,7 @@ class ArrayField(CheckFieldDefaultMixin, Field): error, prefix=self.error_messages['item_invalid'], code='item_invalid', - params={'nth': index}, + params={'nth': index + 1}, ) def formfield(self, **kwargs): diff --git a/django/contrib/postgres/forms/array.py b/django/contrib/postgres/forms/array.py index d9e3256e1f..6c18a37ebf 100644 --- a/django/contrib/postgres/forms/array.py +++ b/django/contrib/postgres/forms/array.py @@ -53,7 +53,7 @@ class SimpleArrayField(forms.CharField): error, prefix=self.error_messages['item_invalid'], code='item_invalid', - params={'nth': index}, + params={'nth': index + 1}, )) if errors: raise ValidationError(errors) @@ -70,7 +70,7 @@ class SimpleArrayField(forms.CharField): error, prefix=self.error_messages['item_invalid'], code='item_invalid', - params={'nth': index}, + params={'nth': index + 1}, )) if errors: raise ValidationError(errors) @@ -86,7 +86,7 @@ class SimpleArrayField(forms.CharField): error, prefix=self.error_messages['item_invalid'], code='item_invalid', - params={'nth': index}, + params={'nth': index + 1}, )) if errors: raise ValidationError(errors) @@ -193,7 +193,7 @@ class SplitArrayField(forms.Field): error, self.error_messages['item_invalid'], code='item_invalid', - params={'nth': index}, + params={'nth': index + 1}, )) cleaned_data.append(None) else: -- cgit v1.2.1