Skip to content

Commit

Permalink
Remove support for assigning None to a SplitField
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mthuurne committed Apr 16, 2024
1 parent a86c14e commit c2d6cb5
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 7 deletions.
3 changes: 0 additions & 3 deletions model_utils/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,6 @@ def __init__(self, field):
def __get__(self, instance, owner):
if instance is None:
raise AttributeError('Can only be accessed via an instance.')
content = instance.__dict__[self.field.name]
if content is None:
return None
return SplitText(instance, self.field.name, self.excerpt_field_name)

def __set__(self, obj, value):
Expand Down
4 changes: 0 additions & 4 deletions tests/test_fields/test_split_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@ def test_access_via_class(self):
with self.assertRaises(AttributeError):
Article.body

def test_none(self):
a = Article(title='Some Title', body=None)
self.assertEqual(a.body, None)

def test_assign_splittext(self):
a = Article(title='Some Title')
a.body = self.post.body
Expand Down

0 comments on commit c2d6cb5

Please sign in to comment.