Fix tests

This commit is contained in:
jeremystretch 2022-01-05 21:21:23 -05:00
parent 85c06372ff
commit 7aa1fabbd7
2 changed files with 8 additions and 1 deletions

View File

@ -251,7 +251,7 @@ class CustomField(ChangeLoggedModel):
if self.type == CustomFieldTypeChoices.TYPE_OBJECT:
return value.pk
if self.type == CustomFieldTypeChoices.TYPE_MULTIOBJECT:
return [obj.pk for obj in value]
return [obj.pk for obj in value] or None
return value
def deserialize(self, value):

View File

@ -52,6 +52,13 @@ class CustomFieldModelFormTest(TestCase):
)
cf_object.content_types.set([obj_type])
cf_multiobject = CustomField.objects.create(
name='multiobject',
type=CustomFieldTypeChoices.TYPE_MULTIOBJECT,
object_type=ContentType.objects.get_for_model(Site)
)
cf_multiobject.content_types.set([obj_type])
def test_empty_values(self):
"""
Test that empty custom field values are stored as null