Skip to content
This repository was archived by the owner on Apr 24, 2025. It is now read-only.

Commit 8f1e078

Browse files
author
mvergerdelbove
committed
compute the document pk value on the fly
1 parent 50d92fe commit 8f1e078

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

mongodbforms/documentoptions.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -204,14 +204,14 @@ def _init_pk(self):
204204
pk_field = None
205205
self.pk = PkWrapper(pk_field)
206206

207-
def _get_pk_val(self):
208-
return self._pk_val
209-
207+
def _get_pk_val(obj):
208+
return obj.pk
209+
210+
patch_document(_get_pk_val, self.document, False) # document is a class...
211+
210212
if pk_field is not None:
211213
self.pk.name = self.pk_name
212214
self.pk.attname = self.pk_name
213-
self.document._pk_val = pk_field
214-
patch_document(_get_pk_val, self.document)
215215
else:
216216
self.pk.fake = True
217217
# this is used in the admin and used to determine if the admin

0 commit comments

Comments
 (0)