Django

Code

Changeset 4878

Show
Ignore:
Timestamp:
03/31/07 04:47:32 (2 years ago)
Author:
mtredinnick
Message:

Fixed #3635 -- Fixed KeyError? problem in newforms.model.save_instance().
Thanks, ludo@qix.it.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/newforms/models.py

    r4553 r4878  
    3737    clean_data = form.clean_data 
    3838    for f in opts.fields: 
    39         if not f.editable or isinstance(f, models.AutoField)
     39        if not f.editable or isinstance(f, models.AutoField) or not f.name in clean_data
    4040            continue 
    4141        setattr(instance, f.name, clean_data[f.name]) 
     
    4343        instance.save() 
    4444        for f in opts.many_to_many: 
    45             setattr(instance, f.attname, clean_data[f.name]) 
     45            if f.name in clean_data: 
     46                setattr(instance, f.attname, clean_data[f.name]) 
    4647    # GOTCHA: If many-to-many data is given and commit=False, the many-to-many 
    4748    # data will be lost. This happens because a many-to-many options cannot be