Ticket #33912: patch_33912.diff

File patch_33912.diff, 1.1 KB (added by François Granade, 2 years ago)

simple patch that fixes the problem. See comments on why it doesn't include a test (yet..)

  • django/db/models/base.py

    diff --git a/django/db/models/base.py b/django/db/models/base.py
    index 1f7e5f84aa..42581a3e26 100644
    a b class Model(metaclass=ModelBase):  
    13221322            if len(unique_check) != len(lookup_kwargs):
    13231323                continue
    13241324
    1325             qs = model_class._default_manager.filter(**lookup_kwargs)
     1325            qs = model_class._default_manager.using(self._state.db).filter(**lookup_kwargs)
    13261326
    13271327            # Exclude the current object from the query if we are editing an
    13281328            # instance (as opposed to creating a new one)
    class Model(metaclass=ModelBase):  
    13631363                )
    13641364            lookup_kwargs[field] = getattr(self, field)
    13651365
    1366             qs = model_class._default_manager.filter(**lookup_kwargs)
     1366            qs = model_class._default_manager.using(self._state.db).filter(**lookup_kwargs)
    13671367            # Exclude the current object from the query if we are editing an
    13681368            # instance (as opposed to creating a new one)
    13691369            if not self._state.adding and self.pk is not None:
Back to Top