Ticket #15130: using_multidb_for_validate_unique.patch

File using_multidb_for_validate_unique.patch, 1.1 KB (added by Tetsuya Morimoto, 13 years ago)

_default_manager "using" multi-db

  • .py

    old new class Model(object):  
    799799            if len(unique_check) != len(lookup_kwargs.keys()):
    800800                continue
    801801
    802             qs = model_class._default_manager.filter(**lookup_kwargs)
     802            qs = model_class._default_manager.using(self._state.db).filter(**lookup_kwargs)
    803803
    804804            # Exclude the current object from the query if we are editing an
    805805            # instance (as opposed to creating a new one)
    class Model(object):  
    830830                lookup_kwargs['%s__%s' % (unique_for, lookup_type)] = getattr(date, lookup_type)
    831831            lookup_kwargs[field] = getattr(self, field)
    832832
    833             qs = model_class._default_manager.filter(**lookup_kwargs)
     833            qs = model_class._default_manager.using(self._state.db).filter(**lookup_kwargs)
    834834            # Exclude the current object from the query if we are editing an
    835835            # instance (as opposed to creating a new one)
    836836            if not self._state.adding and self.pk is not None:
Back to Top