Opened 6 years ago
Closed 6 years ago
#30401 closed Cleanup/optimization (wontfix)
Clarification about when a default value is assigned to a ModelField
Reported by: | Vinicius Assef | Owned by: | nobody |
---|---|---|---|
Component: | Documentation | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
The documentation says in https://docs.djangoproject.com/en/2.2/ref/models/fields/#default at the first paragraph:
The default value for the field. This can be a value or a callable object. If callable it will be called every time a new object is created.
My suggestion is to change the last word above, from "created" to "instantiated" or to "instantiated in memory".
"Created" is confusing with QuerySet.create()
method, leading to the misunderstanding about when the default value is assigned to field.
I myself misunderstood I could use the traditional approach to check if performing an insert or an update in Model.save()
with if self.pk is None
when my pk is an UUIDField
with default=uuid.uuid4
.
Change History (1)
comment:1 by , 6 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
Version: | 2.2 → master |
Thanks for the report, however it is not confusing IMO. Moreover an extra clarification is in the same paragraph
We try to avoid wording changes unless it's a big problem as it creates extra work for documentation translators.