Opened 8 years ago

Closed 5 years ago

#7435 closed (fixed)

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

Reported by: telenieko Owned by: telenieko
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:


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

Download all attachments as: .zip

Change History (7)

comment:1 Changed 8 years ago by telenieko

  • Needs documentation unset
  • Needs tests unset
  • Owner changed from nobody to telenieko
  • Patch needs improvement unset
  • Status changed from new to assigned
  • Triage Stage changed from Unreviewed to Accepted

Changed 8 years ago by telenieko


comment:2 Changed 8 years ago by telenieko

  • Has patch set

Done, that should give a nicer error message. Somebody with a bit more knowledge please check that my use of "" 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 7 years ago by telenieko

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

comment:4 Changed 7 years ago by mtredinnick

  • Triage Stage changed from Accepted to Ready for checkin

Changed 7 years ago by telenieko

New patch (fixes conflict in docs)

comment:5 Changed 5 years ago by mtredinnick

  • Resolution set to fixed
  • Status changed from assigned to closed

(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