Repository: django/django
File: django/db/models/fields/__init__.py (Python)

Code before:
                        obj=self,
                        id="fields.E135",
                    ),
                ]
        else:
            try:
                decimal_places = int(self.decimal_places)
                if decimal_places < 0:
                    raise ValueError()
            except ValueError:
                return [
                    checks.Error(
                        "'decimal_places' must be a non-negative integer.",
                        obj=self,
                        id="fields.E131",
                    )
                ]
        return []

    def _check_max_digits(self):
        if self.max_digits is None:
            if not (
                connection.features.supports_no_precision_decimalfield
                or "supports_no_precision_decimalfield"
                in self.model._meta.required_db_features
            ):
                return [
                    checks.Error(
                        "DecimalFields must define a 'max_digits' attribute.",
                        obj=self,
                        id="fields.E132",
                    )
                ]
            elif self.decimal_places is not None:
                return [
                    checks.Error(
                        "DecimalField’s max_digits and decimal_places must both "
                        "be defined or both omitted.",
                        obj=self,
                        id="fields.E135",
                    ),
                ]
        else:
            try:
                max_digits = int(self.max_digits)
                if max_digits <= 0:
                    raise ValueError()
            except ValueError:
                return [
                    checks.Error(
                        "'max_digits' must be a positive integer.",

Review comment (suggestion):
And here:

```suggestion
            if (
                not connection.features.supports_no_precision_decimalfield
                and "supports_no_precision_decimalfield"
                not in self.model._meta.required_db_features
            ):
```

Code after:
                        obj=self,
                        id="fields.E135",
                    ),
                ]
        else:
            try:
                decimal_places = int(self.decimal_places)
                if decimal_places < 0:
                    raise ValueError()
            except ValueError:
                return [
                    checks.Error(
                        "'decimal_places' must be a non-negative integer.",
                        obj=self,
                        id="fields.E131",
                    )
                ]
        return []

    def _check_max_digits(self):
        if self.max_digits is None:
            if (
                not connection.features.supports_no_precision_decimalfield
                and "supports_no_precision_decimalfield"
                not in self.model._meta.required_db_features
            ):
                return [
                    checks.Error(
                        "DecimalFields must define a 'max_digits' attribute.",
                        obj=self,
                        id="fields.E132",
                    )
                ]
            elif self.decimal_places is not None:
                return [
                    checks.Error(
                        "DecimalField’s max_digits and decimal_places must both "
                        "be defined or both omitted.",
                        obj=self,
                        id="fields.E135",
                    ),
                ]
        else:
            try:
                max_digits = int(self.max_digits)
                if max_digits <= 0:
                    raise ValueError()
            except ValueError:
                return [
                    checks.Error(
                        "'max_digits' must be a positive integer.",