Code

Opened 6 years ago

Closed 4 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:

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

Download all attachments as: .zip

Change History (7)

comment:1 Changed 6 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 6 years ago by telenieko

Patch.

comment:2 Changed 6 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 "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 6 years ago by telenieko

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

comment:4 Changed 6 years ago by mtredinnick

  • Triage Stage changed from Accepted to Ready for checkin

Changed 6 years ago by telenieko

New patch (fixes conflict in docs)

comment:5 Changed 4 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.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.