Code

Ticket #1563: generic-views-manipulator.diff

File generic-views-manipulator.diff, 1.9 KB (added by mir@…, 8 years ago)
Line 
1diff --git a/django/views/generic/create_update.py b/django/views/generic/create_update.py
2index 5637ca5..6c928a4 100644
3--- a/django/views/generic/create_update.py
4+++ b/django/views/generic/create_update.py
5@@ -10,7 +10,8 @@ from django.core.exceptions import Objec
6 
7 def create_object(request, model, template_name=None,
8         template_loader=loader, extra_context={}, post_save_redirect=None,
9-        login_required=False, follow=None, context_processors=None):
10+        login_required=False, follow=None, context_processors=None,
11+        manipulator = None):
12     """
13     Generic object-creation function.
14 
15@@ -21,8 +22,9 @@ def create_object(request, model, templa
16     """
17     if login_required and request.user.is_anonymous():
18         return redirect_to_login(request.path)
19-
20-    manipulator = model.AddManipulator(follow=follow)
21+   
22+    if manipulator == None:
23+        manipulator = model.AddManipulator(follow=follow)
24     if request.POST:
25         # If data was POSTed, we're trying to create a new object
26         new_data = request.POST.copy()
27@@ -73,7 +75,8 @@ def update_object(request, model, object
28         slug_field=None, template_name=None, template_loader=loader,
29         extra_lookup_kwargs={}, extra_context={}, post_save_redirect=None,
30         login_required=False, follow=None, context_processors=None,
31-        template_object_name='object'):
32+        template_object_name='object',
33+        manipulator = None):
34     """
35     Generic object-update function.
36 
37@@ -101,7 +104,8 @@ def update_object(request, model, object
38     except ObjectDoesNotExist:
39         raise Http404, "No %s found for %s" % (model._meta.verbose_name, lookup_kwargs)
40 
41-    manipulator = model.ChangeManipulator(object.id, follow=follow)
42+    if manipulator == None:
43+        manipulator = model.ChangeManipulator(object.id, follow=follow)
44 
45     if request.POST:
46         new_data = request.POST.copy()