Skip to content

Commit e77308c

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

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

django_features/custom_fields/factories.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from factory import SubFactory # type: ignore
44
from factory.django import DjangoModelFactory
55

6-
from app.models import Person
76
from django_features.custom_fields import models
87

98

@@ -12,8 +11,13 @@ class Meta:
1211
model = models.CustomField
1312

1413
@lazy_attribute
15-
def content_type(self) -> ContentType:
16-
return ContentType.objects.get_for_model(Person)
14+
def content_type(self) -> ContentType | None:
15+
try:
16+
from app.models import Person
17+
18+
return ContentType.objects.get_for_model(Person)
19+
except ModuleNotFoundError:
20+
return None
1721

1822
field_type = models.CustomField.FIELD_TYPES.CHAR
1923
identifier = "custom_field"

0 commit comments

Comments
 (0)