Ticket #2360: create_update.diff
File create_update.diff, 2.2 KB (added by , 18 years ago) |
---|
-
django/views/generic/create_update.py
10 10 11 11 def create_object(request, model, template_name=None, 12 12 template_loader=loader, extra_context=None, post_save_redirect=None, 13 login_required=False, follow=None, context_processors=None): 13 login_required=False, follow=None, context_processors=None, 14 extra_content={}, new_manipulator=None, pre_populate=False): 14 15 """ 15 16 Generic object-creation function. 16 17 … … 23 24 if login_required and not request.user.is_authenticated(): 24 25 return redirect_to_login(request.path) 25 26 26 manipulator = model.AddManipulator(follow=follow) 27 if new_manipulator: 28 manipulator = new_manipulator() 29 else: 30 manipulator = model.AddManipulator(follow=follow) 31 27 32 if request.POST: 28 33 # If data was POSTed, we're trying to create a new object 29 34 new_data = request.POST.copy() … … 33 38 34 39 # Check for errors 35 40 errors = manipulator.get_validation_errors(new_data) 41 new_data.update(extra_content) 36 42 manipulator.do_html2python(new_data) 37 43 38 44 if not errors: … … 53 59 else: 54 60 # No POST, so we want a brand new form without any data or errors 55 61 errors = {} 56 new_data = manipulator.flatten_data() 62 if new_manipulator(): 63 new_data = {} 64 # for field in manipulator.fields: 65 # new_data[field] = '' 66 else: 67 new_data = manipulator.flatten_data() 57 68 69 if pre_populate: 70 new_data.update(extra_content) 71 58 72 # Create the FormWrapper, template, context, response 59 73 form = forms.FormWrapper(manipulator, new_data, errors) 60 74 if not template_name: … … 74 88 slug_field=None, template_name=None, template_loader=loader, 75 89 extra_context=None, post_save_redirect=None, 76 90 login_required=False, follow=None, context_processors=None, 77 template_object_name='object' ):91 template_object_name='object', explicit_manipulator=None): 78 92 """ 79 93 Generic object-update function. 80 94