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

Code before:
            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.",
                        obj=self,
                        id="fields.E133",
                    )
                ]
        return []

    def _check_decimal_places_and_max_digits(self, **kwargs):
        if self.decimal_places is None and self.max_digits is None:
            return []
        if int(self.decimal_places) > int(self.max_digits):
            return [
                checks.Error(
                    "'max_digits' must be greater or equal to 'decimal_places'.",
                    obj=self,
                    id="fields.E134",
                )
            ]
        return []

    @cached_property
    def validators(self):
        return [
            *super().validators,
            validators.DecimalValidator(self.max_digits, self.decimal_places),
        ]

    @cached_property
    def context(self):
        return decimal.Context(prec=self.max_digits)

    def deconstruct(self):
        name, path, args, kwargs = super().deconstruct()
        if self.max_digits is not None:

Review comment (suggestion):
If only one of these was `None`, this check would raise a `TypeError`. Maybe this code isn't reachable in that case, but this version is safe even if it becomes reachable:

```suggestion
        if self.decimal_places is None or self.max_digits is None:
```

Code after:
            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.",
                        obj=self,
                        id="fields.E133",
                    )
                ]
        return []

    def _check_decimal_places_and_max_digits(self, **kwargs):
        if self.decimal_places is None or self.max_digits is None:
            return []
        if int(self.decimal_places) > int(self.max_digits):
            return [
                checks.Error(
                    "'max_digits' must be greater or equal to 'decimal_places'.",
                    obj=self,
                    id="fields.E134",
                )
            ]
        return []

    @cached_property
    def validators(self):
        return [
            *super().validators,
            validators.DecimalValidator(self.max_digits, self.decimal_places),
        ]

    @cached_property
    def context(self):
        return decimal.Context(prec=self.max_digits)

    def deconstruct(self):
        name, path, args, kwargs = super().deconstruct()
        if self.max_digits is not None: