Skip to content

Commit 1287106

Browse files
committed
Handle the module not found error for the content type property
1 parent 8bc7508 commit 1287106

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

django_features/custom_fields/factories.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,11 @@ class Meta:
1212
model = models.CustomField
1313

1414
@lazy_attribute
15-
def content_type(self) -> ContentType:
16-
return ContentType.objects.get_for_model(Person)
15+
def content_type(self) -> ContentType | None:
16+
try:
17+
return ContentType.objects.get_for_model(Person)
18+
except ModuleNotFoundError:
19+
return None
1720

1821
field_type = models.CustomField.FIELD_TYPES.CHAR
1922
identifier = "custom_field"

0 commit comments

Comments
 (0)