#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 , 6 years ago
Has patch: | set |
---|---|
Owner: | changed from | to
comment:2 by , 6 years ago
Patch needs improvement: | set |
---|
comment:3 by , 6 years ago
Resolution: | → wontfix |
---|---|
Status: | assigned → closed |
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.
https://github.com/django/django/pull/10742