#30642: Unable to include default value in column_sql when creating new model.
-------------------------------------+-------------------------------------
Reporter: Jeff Cohen | Owner: nobody
Type: | Status: closed
Cleanup/optimization |
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):
* status: new => closed
* type: Bug => Cleanup/optimization
* version: 2.2 => master
* resolution: => invalid
Comment:
Thanks for this report, however it is not a bug, it's rather a design
decision.
Django (for now) doesn't support default values on database level (see
[https://groups.google.com/forum/#!topic/django-
developers/3mcro17Gb40/discussion discussion]). That's why we don't add
`DEFAULT` clause on database creation because no rows would be affected.
We add `DEFAULT` clause when adding a new column to fill existing rows,
but we also immediately drop it after that (see
[https://github.com/django/django/blob/a3417282ac0464a9a2d1d7685bcfef10feed2597/django/db/backends/base/schema.py#L469-L476
add_field()]).
--
Ticket URL: <https://code.djangoproject.com/ticket/30642#comment:3>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/066.3e91fc0712c5a42feff8fb36ceb65e58%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.