Ticket #3079: django_handle_post_arg.diff

File django_handle_post_arg.diff, 2.4 KB (added by Bastian Kleineidam <calvin@…>, 18 years ago)

add handle_post keyword arg

  • django/views/generic/create_update.py

     
    1010
    1111def create_object(request, model, template_name=None,
    1212        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, handle_post=True):
    1414    """
    1515    Generic object-creation function.
    1616
     
    2424        return redirect_to_login(request.path)
    2525
    2626    manipulator = model.AddManipulator(follow=follow)
    27     if request.POST:
     27    if request.POST and handle_post:
    2828        # If data was POSTed, we're trying to create a new object
    2929        new_data = request.POST.copy()
    3030
     
    7474        slug_field=None, template_name=None, template_loader=loader,
    7575        extra_context=None, post_save_redirect=None,
    7676        login_required=False, follow=None, context_processors=None,
    77         template_object_name='object'):
     77        template_object_name='object', handle_post=True):
    7878    """
    7979    Generic object-update function.
    8080
     
    104104
    105105    manipulator = model.ChangeManipulator(getattr(object, object._meta.pk.attname), follow=follow)
    106106
    107     if request.POST:
     107    if request.POST and handle_post:
    108108        new_data = request.POST.copy()
    109109        if model._meta.has_field_type(FileField):
    110110            new_data.update(request.FILES)
     
    148148def delete_object(request, model, post_delete_redirect,
    149149        object_id=None, slug=None, slug_field=None, template_name=None,
    150150        template_loader=loader, extra_context=None,
    151         login_required=False, context_processors=None, template_object_name='object'):
     151        login_required=False, context_processors=None, template_object_name='object', handle_post=True):
    152152    """
    153153    Generic object-delete function.
    154154
     
    178178    except ObjectDoesNotExist:
    179179        raise Http404, "No %s found for %s" % (model._meta.app_label, lookup_kwargs)
    180180
    181     if request.method == 'POST':
     181    if request.method == 'POST' and handle_post:
    182182        object.delete()
    183183        if request.user.is_authenticated():
    184184            request.user.message_set.create(message=gettext("The %(verbose_name)s was deleted.") % {"verbose_name": model._meta.verbose_name})
Back to Top