Ticket #6745: manipulators.py.patch

File manipulators.py.patch, 820 bytes (added by curtis@…, 7 years ago)

Only remove related data on 'change'

  • django/db/models/manipulators.py

    diff -r 6531c7a99496 django/db/models/manipulators.py
    a b class AutomaticManipulator(oldforms.Mani 
    124124                    else:
    125125                        new_vals = new_data.getlist(f.name)
    126126                    # First, clear the existing values.
    127                     rel_manager = getattr(new_object, f.name)
    128                     rel_manager.clear()
     127                    if self.change:
     128                        rel_manager = getattr(new_object, f.name)
     129                        rel_manager.clear()
    129130                    # Then, set the new values.
    130131                    for n in new_vals:
    131132                        rel_manager.add(f.rel.to._default_manager.get(pk=n))
Back to Top