Django

Code

Changeset 4449

Show
Ignore:
Timestamp:
01/29/07 10:12:17 (2 years ago)
Author:
adrian
Message:

Improved newforms.models.save_for_instance() to set many-to-many values via ID instead of instance, to save on a database query, thanks to [4448]

Files:

Legend:

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

    r4439 r4449  
    3838        instance.save() 
    3939        for f in opts.many_to_many: 
    40             setattr(instance, f.attname, getattr(instance, f.attname).model.objects.filter(pk__in = clean_data[f.name])
     40            setattr(instance, f.attname, clean_data[f.name]
    4141    # GOTCHA: If many-to-many data is given and commit=False, the many-to-many 
    4242    # data will be lost. This happens because a many-to-many options cannot be