#15274 closed (fixed)
UpdateView raises exception about overiding get_object
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Generic views | Version: | 1.3-beta |
Severity: | Keywords: | blocker | |
Cc: | Triage Stage: | Accepted | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
I've defined the view class:
class OneAuthorUpdate(generic.UpdateView): def get_object(self): return Author.objects.get(pk=1)
But next exception raises:
ImproperlyConfigured: OneAuthorUpdate is missing a queryset. Define OneAuthorUpdate.model, OneAuthorUpdate.queryset, or override OneAuthorUpdate.get_object()
Attachments (1)
Change History (6)
by , 14 years ago
Attachment: | tests_for_get_object.patch added |
---|
comment:1 by , 14 years ago
Keywords: | blocker added |
---|---|
milestone: | → 1.3 |
Triage Stage: | Unreviewed → Accepted |
Confirmed that the test case fails as described; need to dig in closer to see exactly why. Marking as a blocker for the moment, because at the very least, it's confusing.
comment:2 by , 14 years ago
I've found the cause -- you've overridden get_object, but you haven't provided a form, so the call to get_form_class() is calling get_queryset() as a cheats way to find the model that can be used to automatically construct a ModelForm.
The simple workaround -- specify a form_class. I'm looking into what we can do as a permanent solution.
comment:3 by , 14 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Tests for UpdateView and get_object method