Opened 18 years ago

Closed 17 years ago

#3484 closed (duplicate)

Poor error message (or functionality) when using unsaved models as foreign keys

Reported by: Dave Abrahams <dave@…> Owned by: nobody
Component: Database layer (models, ORM) Version: dev
Severity: Keywords:
Cc: Triage Stage: Design decision needed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

This reduced case untested, sorry.

from django.db import models

class X(models.Model):
    pass

class Y(models.Model):
    x = models.ForeignKey(X)

x = X()
Y(x=x).save()

The result,
IntegrityError: ERROR: null value in column "presenter_id" violates not-null constraint, is cryptic at best. Maybe rather than improving the error message, it should recursively save all unsaved models?

Change History (4)

comment:1 by Dave Abrahams <dave@…>, 18 years ago

Oops, not presenter_id, but x_id

comment:2 by Chris Beaven, 18 years ago

Triage Stage: UnreviewedDesign decision needed

I think just improving the error message would be enough. But what does core think?

comment:3 by Chris Beaven, 18 years ago

Summary: Poor error message (or functionality)Poor error message (or functionality) when using unsaved models as foreign keys

comment:4 by James Bennett, 17 years ago

Resolution: duplicate
Status: newclosed

Duplicate of #3016, I believe; fixing that should fix this.

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