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.
This commit is contained in:
Maarten ter Huurne 2024-04-16 08:01:17 +02:00
parent a86c14e4e7
commit c2d6cb5021
2 changed files with 0 additions and 7 deletions

View file

@ -208,9 +208,6 @@ class SplitDescriptor:
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):

View file

@ -53,10 +53,6 @@ class SplitFieldTests(TestCase):
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