Opened 5 years ago

Closed 5 years ago

#24565 closed New feature (duplicate)

server_default option on model fields

Reported by: Pacodastre Owned by: nobody
Component: Database layer (models, ORM) Version: 1.8
Severity: Normal Keywords:
Cc: ribemont.francois@… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I'll just be talking about PostgreSQL, since it's the only one i've been using, but it might also be possible with other Database Engines.

When you set a default on a field such as:

my_field = models.BooleanField(default=True)

This default is not applied to the PostgreSQL table:

           Table "public.app_mytable"
     Column      |           Type           | Modifiers 
-----------------+--------------------------+-----------
 my_field        | boolean                  | not null

SQLAlchemy provides a server_default option.

It would be nice to have such an option in Django too.

Change History (1)

comment:1 Changed 5 years ago by Tim Graham

Resolution: duplicate
Status: newclosed

Duplicate of #470. To revisit the discussion please use the DevelopersMailingList (and please search for existing discussion on the topic first).

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