Ticket #6211: save_instance.2.diff

File save_instance.2.diff, 1.1 KB (added by Seth Buntin, 17 years ago)

Patch to fix TypeError? issue. Checks for fields before acting upon it.

  • Users/seth/django_src/django/newforms/models.py

     
    3939        if not f.editable or isinstance(f, models.AutoField) \
    4040                or not f.name in cleaned_data:
    4141            continue
    42         if fields and f.name not in fields:
    43             continue
     42        if fields:
     43            if f.name not in fields:
     44                continue
    4445        f.save_form_data(instance, cleaned_data[f.name])
    4546    # Wrap up the saving of m2m data as a function.
    4647    def save_m2m():
    4748        opts = instance.__class__._meta
    4849        cleaned_data = form.cleaned_data
    4950        for f in opts.many_to_many:
    50             if fields and f.name not in fields:
    51                 continue
     51            if fields:
     52                if f.name not in fields:
     53                    continue
    5254            if f.name in cleaned_data:
    5355                f.save_form_data(instance, cleaned_data[f.name])
    5456    if commit:
Back to Top