Opened 3 years ago

Closed 3 years ago

#18236 closed Uncategorized (wontfix)

keyword parameter naming collision with get_object_or_404

Reported by: anonymous Owned by: nobody
Component: Core (Other) Version: 1.4
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

A model with a field named "klass" breaks get_object_or_404.

Change History (1)

comment:1 Changed 3 years ago by akaariai

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to wontfix
  • Status changed from new to closed

You can wrap the klass='someclass' filter into django.db.models.Q(klass='someclass') and things should work. So, instead of:

get_object_or_404(klass='someclass')

do

from django.db.models import Q
get_object_or_404(Q(klass='someclass'))

I am marking this as wontfix, as this condition is IMO rare enough to not warrant any fixes.

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