Skip to content

Commit c2d6cb5

Browse files
committed
Remove support for assigning None to a SplitField
This behavior wasn't documented and didn't fully work: it breaks as soon as you try to save a model with a `None` value.
1 parent a86c14e commit c2d6cb5

File tree

2 files changed

+0
-7
lines changed

2 files changed

+0
-7
lines changed

model_utils/fields.py

-3
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,6 @@ def __init__(self, field):
208208
def __get__(self, instance, owner):
209209
if instance is None:
210210
raise AttributeError('Can only be accessed via an instance.')
211-
content = instance.__dict__[self.field.name]
212-
if content is None:
213-
return None
214211
return SplitText(instance, self.field.name, self.excerpt_field_name)
215212

216213
def __set__(self, obj, value):

tests/test_fields/test_split_field.py

-4
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,6 @@ def test_access_via_class(self):
5353
with self.assertRaises(AttributeError):
5454
Article.body
5555

56-
def test_none(self):
57-
a = Article(title='Some Title', body=None)
58-
self.assertEqual(a.body, None)
59-
6056
def test_assign_splittext(self):
6157
a = Article(title='Some Title')
6258
a.body = self.post.body

0 commit comments

Comments
 (0)