Ticket #2262: django-db-models-manipulators.diff

File django-db-models-manipulators.diff, 914 bytes (added by rayners@…, 9 years ago)

Patch to check for blank ManyToManyField

  • django/db/models/manipulators.py

     
    214214
    215215                        # Save many-to-many objects.
    216216                        for f in related.opts.many_to_many:
    217                             if child_follow.get(f.name, None) and not f.rel.edit_inline:
     217                            if child_follow.get(f.name, None) and not f.rel.edit_inline and not (f.blank and not hasattr(new_rel_obj, 'set_%s' % f.name)):
    218218                                was_changed = getattr(new_rel_obj, 'set_%s' % f.name)(rel_new_data[f.attname])
    219219                                if self.change and was_changed:
    220220                                    self.fields_changed.append('%s for %s "%s"' % (f.verbose_name, related.opts.verbose_name, new_rel_obj))
Back to Top