Opened 8 years ago

Closed 6 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: master
Severity: Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

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 8 years ago.
Patch.
7435.newdocs.diff (1.1 KB) - added by Marc Fargas 8 years ago.
New patch (fixes conflict in docs)

Download all attachments as: .zip

Change History (7)

comment:1 Changed 8 years ago by Marc Fargas

Needs documentation: unset
Needs tests: unset
Owner: changed from nobody to Marc Fargas
Patch needs improvement: unset
Status: newassigned
Triage Stage: UnreviewedAccepted

Changed 8 years ago by Marc Fargas

Attachment: 7435.diff added

Patch.

comment:2 Changed 8 years ago by Marc Fargas

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 Changed 8 years ago by Marc Fargas

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

comment:4 Changed 8 years ago by Malcolm Tredinnick

Triage Stage: AcceptedReady for checkin

Changed 8 years ago by Marc Fargas

Attachment: 7435.newdocs.diff added

New patch (fixes conflict in docs)

comment:5 Changed 6 years ago by Malcolm Tredinnick

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