Opened 5 years ago

Closed 5 years ago

#16077 closed Bug (invalid)

syncdb, PostgreSQL: models.IntegerField default value is absent in the created SQL

Reported by: maretskiy@… Owned by: nobody
Component: Database layer (models, ORM) Version: 1.3
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:


If some model has an IntegerField with option "default" set, then "./ syncdb" will create PostgreSQL table with integer field without "DEFAULT" SQL keyword. So that is impossible to set default value for this model attribute.



class AmProfile(models.Model):

my_field = models.IntegerField(default=1)

produced SQL:

my_field integer NOT NULL,

but should be:

my_field integer DEFAULT 1 NOT NULL,

Change History (1)

comment:1 Changed 5 years ago by aaugustin

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to closed

The default value can be a value or a callable, so it's not possible to include it in the generated SQL.

However, it will still be used whenever you create a new instance of your model.


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