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

Improve support to django model translation fields #1304

Closed
wants to merge 4 commits into from
Closed
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 AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ Authors
- Miguel Vargas
- Mike Spainhower
- Muneeb Shahid (`muneeb706 <https://github.com/muneeb706>`_)
- Natanael Maia (`natanrmaia <https://github.com/natanrmaia/>`_)
- Nathan Villagaray-Carski (`ncvc <https://github.com/ncvc>`_)
- Nianpeng Li
- Nick Träger
Expand Down
10 changes: 10 additions & 0 deletions simple_history/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,16 @@
for field in self.fields_included(model):
field = copy.copy(field)
field.remote_field = copy.copy(field.remote_field)
if field.__class__.__name__ == "TranslationCharField":
old_field = field
field.__class__ = models.CharField

Check warning on line 335 in simple_history/models.py

View check run for this annotation

Codecov / codecov/patch

simple_history/models.py#L334-L335

Added lines #L334 - L335 were not covered by tests
if hasattr(field, "max_length"):
field.max_length = (

Check warning on line 337 in simple_history/models.py

View check run for this annotation

Codecov / codecov/patch

simple_history/models.py#L337

Added line #L337 was not covered by tests
old_field.max_length if old_field.max_length else 255
)
if field.__class__.__name__ == "TranslationTextField":
old_field = field
field.__class__ = models.TextField

Check warning on line 342 in simple_history/models.py

View check run for this annotation

Codecov / codecov/patch

simple_history/models.py#L341-L342

Added lines #L341 - L342 were not covered by tests
if isinstance(field, OrderWrt):
# OrderWrt is a proxy field, switch to a plain IntegerField
field.__class__ = models.IntegerField
Expand Down