Code

Ticket #2859: create_update.diff

File create_update.diff, 1.1 KB (added by anonymous, 8 years ago)

Patch

Line 
1Index: django/views/generic/create_update.py
2===================================================================
3--- django/views/generic/create_update.py       (revision 3889)
4+++ django/views/generic/create_update.py       (working copy)
5@@ -70,7 +70,7 @@
6             c[key] = value
7     return HttpResponse(t.render(c))
8 
9-def update_object(request, model, object_id=None, slug=None,
10+def update_object(request, model, queryset=None, object_id=None, slug=None,
11         slug_field=None, template_name=None, template_loader=loader,
12         extra_context=None, post_save_redirect=None,
13         login_required=False, follow=None, context_processors=None,
14@@ -98,7 +98,10 @@
15     else:
16         raise AttributeError("Generic edit view must be called with either an object_id or a slug/slug_field")
17     try:
18-        object = model.objects.get(**lookup_kwargs)
19+        if queryset:
20+            object = queryset.get(**lookup_kwargs)
21+        else:
22+            object = model.objects.get(**lookup_kwargs)
23     except ObjectDoesNotExist:
24         raise Http404, "No %s found for %s" % (model._meta.verbose_name, lookup_kwargs)
25