Opened 17 years ago
Closed 17 years ago
#4800 closed (duplicate)
Field's default value in model isn't passed to SQL
Reported by: | Owned by: | Adrian Holovaty | |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | dev |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Design decision needed | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | yes |
Easy pickings: | no | UI/UX: | no |
Description
I have a model roughly like this:
class Foo(models.Model): blah = models.BooleanField(default=True)
I expect "syncdb" to create SQL field with the default value set (this is for mysql):
`blah` tinyint(1) NOT NULL DEFAULT '1',
Unfortunately it doesn't, the "DEFAULT '1'" part is missing. Apparently there is no checking for 'field.default' value in django/core/management.py:_get_sql_model_create()
Attached patch adds this functionality.
Attachments (1)
Change History (3)
by , 17 years ago
Attachment: | db-default.diff added |
---|
comment:1 by , 17 years ago
Patch needs improvement: | set |
---|---|
Triage Stage: | Unreviewed → Design decision needed |
comment:2 by , 17 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
Dupe of #470 (which has been wontfixed twice so far).
Note:
See TracTickets
for help on using tickets.
A couple things:
BooleanField
.