Opened 16 years ago

Closed 14 years ago

#7435 closed (fixed)

get_{next,previous}_by_someDateField() on unsaved objects should throw meaningfull error

Reported by: Marc Fargas Owned by: Marc Fargas
Component: Core (Other) Version: dev
Severity: Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

As stated on this thread when you call self.get_{next,previous}_by_someDateField() on an unsaved object Django says something like:

"Cannot use None as a query"

The error could be something easier to understand like "Cannot query over an unsaved object".

Attachments (2)

7435.diff (1.2 KB ) - added by Marc Fargas 16 years ago.
Patch.
7435.newdocs.diff (1.1 KB ) - added by Marc Fargas 16 years ago.
New patch (fixes conflict in docs)

Download all attachments as: .zip

Change History (7)

comment:1 by Marc Fargas, 16 years ago

Owner: changed from nobody to Marc Fargas
Status: newassigned
Triage Stage: UnreviewedAccepted

by Marc Fargas, 16 years ago

Attachment: 7435.diff added

Patch.

comment:2 by Marc Fargas, 16 years ago

Has patch: set

Done, that should give a nicer error message. Somebody with a bit more knowledge please check that my use of "self.pk" is correct.

No test have been written as this should need it's own test (from my POV), only pass those already there ;)

comment:3 by Marc Fargas, 16 years ago

The docs-refactor broke the patch, always up-to-date patch here in colours and raw

comment:4 by Malcolm Tredinnick, 16 years ago

Triage Stage: AcceptedReady for checkin

by Marc Fargas, 16 years ago

Attachment: 7435.newdocs.diff added

New patch (fixes conflict in docs)

comment:5 by Malcolm Tredinnick, 14 years ago

Resolution: fixed
Status: assignedclosed

(In [13738]) Better error message for calling get_next_by_* on unsaved models.
Patch from Marc Fargas. Fixed #7435.

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