Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove excerpt field workaround for South FakeORM #610

Merged
merged 2 commits into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ To be released
- Don't use `post_init` signal for initialize tracker
- Make `contribute_to_class()` in `StatusField`, `MonitorField` and `SplitField`
forward additional arguments to Django
- `SplitField` no longer accepts `no_excerpt_field` as a keyword argument

4.4.0 (2024-02-10)
------------------
Expand Down
15 changes: 1 addition & 14 deletions model_utils/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,16 +222,8 @@ def __set__(self, obj, value):


class SplitField(models.TextField):
def __init__(self, *args, no_excerpt_field=False, **kwargs):
# for South FakeORM compatibility: the frozen version of a
# SplitField can't try to add an _excerpt field, because the
# _excerpt field itself is frozen as well. See introspection
# rules below.
self.add_excerpt_field = not no_excerpt_field
super().__init__(*args, **kwargs)

def contribute_to_class(self, cls, name, *args, **kwargs):
if self.add_excerpt_field and not cls._meta.abstract:
if not cls._meta.abstract:
excerpt_field = models.TextField(editable=False)
cls.add_to_class(_excerpt_field_name(name), excerpt_field)
super().contribute_to_class(cls, name, *args, **kwargs)
Expand All @@ -253,11 +245,6 @@ def get_prep_value(self, value):
except AttributeError:
return value

def deconstruct(self):
name, path, args, kwargs = super().deconstruct()
kwargs['no_excerpt_field'] = True
return name, path, args, kwargs


class UUIDField(models.UUIDField):
"""
Expand Down
Loading