In addition to @sj95126's comment.
What does the deconstruct
method do:
... - in particular, what arguments to pass to
__init__()
to re-create it.
For example, in our
HandField
class we’re always forcibly setting max_length in__init__()
. Thedeconstruct()
method on the baseField
class will see this and try to return it in the keyword arguments; thus, we can drop it from the keyword arguments for readability:
Consider the following examples:
from django.db import models
class ModelOne(models.Model):
hand = HandField(max_length=50)
class ModelTwo(models.Model):
hand = HandField()
So, whether you pass max_length
or not, the value is same for
ModelOne
and ModelTwo
because it has already been pre-defined
in the __init__
initialiser.
It is dropped for readability
. Dropping it or not doesn't matter
because it is always defined in __init__.