1
0
mirror of https://github.com/django/django.git synced 2025-04-25 09:44:36 +00:00

Refs #31435 -- Doc'd potential infinite recursion when accessing model fields in __init__.

This commit is contained in:
David Sanders 2023-09-19 18:07:22 +10:00 committed by Natalia
parent 91cb2d0b48
commit e47298aec4

View File

@ -30,7 +30,9 @@ need to :meth:`~Model.save()`.
You may be tempted to customize the model by overriding the ``__init__`` You may be tempted to customize the model by overriding the ``__init__``
method. If you do so, however, take care not to change the calling method. If you do so, however, take care not to change the calling
signature as any change may prevent the model instance from being saved. signature as any change may prevent the model instance from being saved.
Rather than overriding ``__init__``, try using one of these approaches: Additionally, referring to model fields within ``__init__`` may potentially
result in infinite recursion errors in some circumstances. Rather than
overriding ``__init__``, try using one of these approaches:
#. Add a classmethod on the model class:: #. Add a classmethod on the model class::