class AddField(model_name, name, field, preserve_default=True)
[source]
Adds a field to a model. model_name
is the model’s name, name
is the field’s name, and field
is an unbound Field instance (the thing you would put in the field declaration in models.py
- for example, models.IntegerField(null=True)
.
The preserve_default
argument indicates whether the field’s default value is permanent and should be baked into the project state (True
), or if it is temporary and just for this migration (False
) - usually because the migration is adding a non-nullable field to a table and needs a default value to put into existing rows. It does not affect the behavior of setting defaults in the database directly - Django never sets database defaults and always applies them in the Django ORM code.
Please login to continue.