Django

Code

Ticket #2231 (closed: invalid)

Opened 3 years ago

Last modified 8 months ago

Boolean fields don't honor 'default' parameter

Reported by: russellm Assigned to: russellm
Milestone: Component: Database layer (models, ORM)
Version: Keywords: boolean default
Cc: martinson.jacob@gmail.com, freakboy3742@gmail.com, hv@tbz-pariv.de Triage Stage: Unreviewed
Has patch: 0 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

Jacob Martinson <martinson.jacob@gmail.com> reports that in the model:

class Response(models.Model):
      responded = models.BooleanField(default=False)

The postgresql table that gets created does not have a default value for the "responded" column and I get a sql exception if I don't manually set responded to 'f' when I save each new Response object.

Attachments

Change History

06/25/06 01:54:07 changed by russellm

Further investigation reveals that this might not actually be a problem - Follow the user mailing list thread ("Default value for boolean field") for more details.

06/25/06 19:14:38 changed by mtredinnick

  • status changed from new to closed.
  • resolution set to invalid.

Looks to be completely unrepeatable now (even by Jacob). Please reopen if it appears again.

11/11/08 04:07:29 changed by guettli

  • cc changed from martinson.jacob@gmail.com, freakboy3742@gmail.com to martinson.jacob@gmail.com, freakboy3742@gmail.com, hv@tbz-pariv.de.
  • status changed from closed to reopened.
  • resolution deleted.

It is repeatable:

Current trunk

cd django/trunk; svn update
...
Aktualisiert zu Revision 9391.
django-admin startapp booltest

# booltest/models.py
from django.db import models
class TestModel(models.Model):
    truth=models.BooleanField(default=False)
>django-admin.py sqlall booltest

BEGIN;
CREATE TABLE "booltest_testmodel" (
    "id" serial NOT NULL PRIMARY KEY,
    "truth" boolean NOT NULL
)
;
COMMIT;

DATABASE_ENGINE = 'postgresql_psycopg2'

I expected:

  ...
  "truth" boolean NOT NULL DEFAULT FALSE

11/11/08 06:02:09 changed by russellm

Default isn't handled at the SQL level - it's handled at the model level.

11/11/08 06:25:33 changed by russellm

  • status changed from reopened to closed.
  • resolution set to invalid.

Add/Change #2231 (Boolean fields don't honor 'default' parameter)




Change Properties
Action