[Django] #30030: SingleObjectMixin raises misleading AttributeError when called witout pk or slug

11 views
Skip to first unread message

Django

unread,
Dec 10, 2018, 9:26:53 PM12/10/18
to django-...@googlegroups.com
#30030: SingleObjectMixin raises misleading AttributeError when called witout pk or
slug
-----------------------------------------+--------------------------
Reporter: oliver | Owner: oliver
Type: Bug | Status: assigned
Component: Generic views | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+--------------------------
{{{
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.

--
Ticket URL: <https://code.djangoproject.com/ticket/30030>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Dec 10, 2018, 9:55:07 PM12/10/18
to django-...@googlegroups.com
#30030: SingleObjectMixin raises misleading AttributeError when called witout pk or
slug
-------------------------------+--------------------------------------

Reporter: oliver | Owner: oliver
Type: Bug | Status: assigned
Component: Generic views | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by oliver):

* owner: oliver => oliver
* has_patch: 0 => 1


Comment:

https://github.com/django/django/pull/10742

--
Ticket URL: <https://code.djangoproject.com/ticket/30030#comment:1>

Django

unread,
Dec 17, 2018, 8:13:14 PM12/17/18
to django-...@googlegroups.com
#30030: SingleObjectMixin raises misleading AttributeError when called witout pk or
slug
-------------------------------+--------------------------------------

Reporter: oliver | Owner: oliver
Type: Bug | Status: assigned
Component: Generic views | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by oliver):

* needs_better_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/30030#comment:2>

Django

unread,
Dec 19, 2018, 5:24:57 AM12/19/18
to django-...@googlegroups.com
#30030: SingleObjectMixin raises misleading AttributeError when called witout pk or
slug
-------------------------------+--------------------------------------
Reporter: oliver | Owner: oliver
Type: Bug | Status: closed

Component: Generic views | Version: master
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by Carlton Gibson):

* status: assigned => closed
* resolution: => wontfix


Comment:

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

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.

--
Ticket URL: <https://code.djangoproject.com/ticket/30030#comment:3>

Reply all
Reply to author
Forward
0 new messages