Skip to content

Commit

Permalink
use related_field_model_attr in Singleton model mixin
Browse files Browse the repository at this point in the history
  • Loading branch information
erikvw committed Aug 11, 2023
1 parent 6c04306 commit 32eaa3b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions edc_crf/modelform_mixins/crf_singleton_model_form_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ def raise_if_singleton_exists(self: MyForm) -> None:
timepoint.
"""
if not self.instance.id:
opts = {
f"{self.related_visit_model_attr}__subject_identifier": self.subject_identifier
}
try:
obj = self._meta.model.objects.get(
subject_visit__subject_identifier=self.subject_identifier
)
obj = self._meta.model.objects.get(**opts)
except ObjectDoesNotExist:
pass
else:
Expand Down

0 comments on commit 32eaa3b

Please sign in to comment.