diff --git a/django/forms/models.py b/django/forms/models.py
index 5fcf959..c5afc08 100644
a
|
b
|
class BaseModelFormSet(BaseFormSet):
|
431 | 431 | |
432 | 432 | def _existing_object(self, pk): |
433 | 433 | if not hasattr(self, '_object_dict'): |
434 | | self._object_dict = dict([(o.pk, o) for o in self.get_queryset()]) |
| 434 | from django.db import connections |
| 435 | self._object_dict = {} |
| 436 | dct = self._object_dict |
| 437 | for o in self.get_queryset(): |
| 438 | d_key = self.model._meta.pk.get_db_prep_lookup('exact', o.pk, connection=connections[self.get_queryset().db]) |
| 439 | if isinstance(d_key, list): |
| 440 | d_key = d_key[0] |
| 441 | dct[d_key] = o |
435 | 442 | return self._object_dict.get(pk) |
436 | 443 | |
437 | 444 | def _construct_form(self, i, **kwargs): |