Ticket #1563: generic-views-manipulator.2.diff

File generic-views-manipulator.2.diff, 1.8 KB (added by mir@…, 9 years ago)
  • django/views/generic/create_update.py

    a b from django.core.exceptions import Objec 
    1010
    1111def create_object(request, model, template_name=None,
    1212        template_loader=loader, extra_context={}, post_save_redirect=None,
    13         login_required=False, follow=None, context_processors=None):
     13        login_required=False, follow=None, context_processors=None,
     14        manipulator = None):
    1415    """
    1516    Generic object-creation function.
    1617
    def create_object(request, model, templa 
    2122    """
    2223    if login_required and request.user.is_anonymous():
    2324        return redirect_to_login(request.path)
    24 
    25     manipulator = model.AddManipulator(follow=follow)
     25   
     26    if manipulator == None:
     27        manipulator = model.AddManipulator(follow=follow)
    2628    if request.POST:
    2729        # If data was POSTed, we're trying to create a new object
    2830        new_data = request.POST.copy()
    def update_object(request, model, object 
    7375        slug_field=None, template_name=None, template_loader=loader,
    7476        extra_lookup_kwargs={}, extra_context={}, post_save_redirect=None,
    7577        login_required=False, follow=None, context_processors=None,
    76         template_object_name='object'):
     78        template_object_name='object',
     79        manipulator = None):
    7780    """
    7881    Generic object-update function.
    7982
    def update_object(request, model, object 
    101104    except ObjectDoesNotExist:
    102105        raise Http404, "No %s found for %s" % (model._meta.verbose_name, lookup_kwargs)
    103106
    104     manipulator = model.ChangeManipulator(object.id, follow=follow)
     107    if manipulator == None:
     108        manipulator = model.ChangeManipulator(object.id, follow=follow)
    105109
    106110    if request.POST:
    107111        new_data = request.POST.copy()
Back to Top