Ticket #2254: create_update.patch

File create_update.patch, 1.6 KB (added by djangoblog@…, 18 years ago)

Patch to add override_dict to create/update views

  • 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,
     14        override_dict=None):
    1415    """
    1516    Generic object-creation function.
    1617
     
    3132        if model._meta.has_field_type(FileField):
    3233            new_data.update(request.FILES)
    3334
     35        if override_dict is not None:
     36            new_data.update(override_dict)
     37
    3438        # Check for errors
    3539        errors = manipulator.get_validation_errors(new_data)
    3640        manipulator.do_html2python(new_data)
     
    7478        slug_field=None, template_name=None, template_loader=loader,
    7579        extra_context=None, post_save_redirect=None,
    7680        login_required=False, follow=None, context_processors=None,
    77         template_object_name='object'):
     81        template_object_name='object', override_dict=None):
    7882    """
    7983    Generic object-update function.
    8084
     
    108112        new_data = request.POST.copy()
    109113        if model._meta.has_field_type(FileField):
    110114            new_data.update(request.FILES)
     115        if override_dict is not None:
     116            new_data.update(override_dict)
    111117        errors = manipulator.get_validation_errors(new_data)
    112118        manipulator.do_html2python(new_data)
    113119        if not errors:
Back to Top