Skip to content

Commit

Permalink
Merge pull request #433 from infofactory/fix/inherited-fields
Browse files Browse the repository at this point in the history
Fix inherited fields when using django-modeltranslation >= 0.19
  • Loading branch information
DiogoMarques29 authored Dec 19, 2024
2 parents 5be804b + a4863c2 commit 4ddac39
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
strategy:
matrix:
python: ["3.8", "3.9", "3.10", "3.11", "3.12"]
django-modeltranslation: ["0.17", "0.18"]
django-modeltranslation: ["0.19"]
wagtail: ["5.2", "6.0"]
database: ["sqlite", "postgres", "mysql"]
env:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ classifiers = [
python = "^3.8"
Django = ">=4.2"
wagtail = ">=5.2,<=7.0"
django-modeltranslation = ">=0.17"
django-modeltranslation = ">=0.19"

[tool.poetry.dev-dependencies]
bump2version = "^1.0.1"
Expand Down
10 changes: 5 additions & 5 deletions wagtail_modeltranslation/patch_wagtailadmin.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def __init__(self, model):
WagtailTranslator._patched_models.append(model)

def _patch_fields(self, model):
translation_registered_fields = translator.get_options_for_model(model).fields
translation_registered_fields = translator.get_options_for_model(model).all_fields

model_fields = model._meta.get_fields()
for field in model_fields:
Expand Down Expand Up @@ -108,7 +108,7 @@ def _patch_page_models(self, model):

# SEARCH FIELDS PATCHING

translation_registered_fields = translator.get_options_for_model(model).fields
translation_registered_fields = translator.get_options_for_model(model).all_fields

for field in model.search_fields:
# Check if the field is a SearchField and if it is one of the fields registered for translation
Expand Down Expand Up @@ -170,7 +170,7 @@ def _patch_other_models(self, model):
def _patch_ObjectList(self, obj_list, model):
translation_registered_fields = translator.get_options_for_model(
model
).fields
).all_fields
panels = list(
filter(
lambda field: field.field_name not in translation_registered_fields,
Expand Down Expand Up @@ -206,7 +206,7 @@ def _patch_panels(self, panels_list, related_model=None):
def _patch_simple_panel(self, model, original_panel):
panel_class = original_panel.__class__
translated_panels = []
translation_registered_fields = translator.get_options_for_model(model).fields
translation_registered_fields = translator.get_options_for_model(model).all_fields

# If the panel field is not registered for translation
# the original one is returned
Expand Down Expand Up @@ -307,7 +307,7 @@ def _patch_inline_panel(self, model, panel):
panels = extract_panel_definitions_from_model_class(related_model)
translation_registered_fields = translator.get_options_for_model(
related_model
).fields
).all_fields
panels = list(
filter(
lambda field: field.field_name
Expand Down

0 comments on commit 4ddac39

Please sign in to comment.