Opened 18 months ago

Closed 5 days ago

Last modified 5 days ago

#35786 closed Bug (fixed)

AddField reference to Django's support for database defaults is outdated

Reported by: Václav Řehák Owned by: Ahmed Nassar
Component: Documentation Version: 5.1
Severity: Normal Keywords: db_default
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The docs of AddField at https://docs.djangoproject.com/en/dev/ref/migration-operations/#addfield says

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.

I think this wording is confusing because since adding db_default Django ORM actually does set db defaults. The same sentence is present in AlterField docs.

Change History (7)

comment:1 by Václav Řehák, 18 months ago

Btw, there was already a comment about this 8 years ago, see https://code.djangoproject.com/ticket/26476#comment:3

"arguably, the documentation is not clear enough; what is meant is that Django never leaves defaults in the database."

comment:2 by Jacob Walls, 18 months ago

Keywords: db_default added
Summary: Incorrect info about database defaults in migrations docAddField reference to Django's support for database defaults is outdated
Triage Stage: UnreviewedAccepted

Nice catch!

comment:3 by Virender121, 18 months ago

Owner: set to Virender121
Status: newassigned

comment:4 by Ahmed Nassar, 11 months ago

Owner: changed from Virender121 to Ahmed Nassar

Due to owner's inactivity. I'll work on this ticket and submit my PR soon.

comment:5 by Ahmed Nassar, 5 days ago

Has patch: set

comment:6 by GitHub <noreply@…>, 5 days ago

Resolution: fixed
Status: assignedclosed

In 23f49c6:

Fixed #35786 -- Removed outdated note about database defaults in AddField/AlterField docs.

comment:7 by Mariusz Felisiak <felisiak.mariusz@…>, 5 days ago

In fc4bcb35:

[6.0.x] Fixed #35786 -- Removed outdated note about database defaults in AddField/AlterField docs.

Backport of 23f49c6b408d9b013e959f91c23813a7c0f6ed64 from main

Note: See TracTickets for help on using tickets.
Back to Top