Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#30030 closed Bug (wontfix)

SingleObjectMixin raises misleading AttributeError when called witout pk or slug

Reported by: oliver Owned by: oliver
Component: Generic views Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

class FooUpdateView(django.views.generic.UpdateView):
    model = Foo
    form_class = FooForm
    template_name = 'foo.html'
urlpatterns = [
    url(^'foo/$', FooUpdateView,as_view(), name='detal'),
]

In above code, If a user calls foo/, following AttributeError will be raised.
Generic detail view FooUpdateView must be called with either an object pk or a slug in the URLconf.

FooUpdateView raises the error even though it isn't generic detail view.
Also CreateView has this issue because it inherits from SingleObjectMixin.

Change History (3)

comment:1 by oliver, 6 years ago

Has patch: set
Owner: changed from oliver to oliver

comment:2 by oliver, 6 years ago

Patch needs improvement: set

comment:3 by Carlton Gibson, 6 years ago

Resolution: wontfix
Status: assignedclosed

The error message here has been unchanged since class-based views were first introduced in 0fcb09455729113f64a9873ca40bffd009b9bc5f for #6735.

The phrasing "generic detail view" captures not a specific view class but the group of all descendants of SingleObjectMixin (otherwise it would be GenericDetailView...) There are (I think) 11 of those. It reflects the view.generic.detail module naming. I think it's fine vs the proposed that inherits from SingleObjectMixin alteration.


Last edited 6 years ago by Carlton Gibson (previous) (diff)
Note: See TracTickets for help on using tickets.
Back to Top