mirror of
https://github.com/Hopiu/django-modeltranslation.git
synced 2026-05-03 19:14:42 +00:00
chore: Update formatting
This commit is contained in:
parent
3c0735ca96
commit
f0fb6ebd8d
5 changed files with 8 additions and 9 deletions
|
|
@ -175,7 +175,7 @@ class TranslationBaseModelAdmin(BaseModelAdmin):
|
|||
def _patch_fieldsets(self, fieldsets):
|
||||
if fieldsets:
|
||||
fieldsets_new = list(fieldsets)
|
||||
for (name, dct) in fieldsets:
|
||||
for name, dct in fieldsets:
|
||||
if 'fields' in dct:
|
||||
dct['fields'] = self.replace_orig_field(dct['fields'])
|
||||
fieldsets = fieldsets_new
|
||||
|
|
|
|||
|
|
@ -163,7 +163,6 @@ class TranslationField:
|
|||
if isinstance(self.translated_field, fields.related.ManyToManyField) and hasattr(
|
||||
self.remote_field, "through"
|
||||
):
|
||||
|
||||
# Since fields cannot share the same remote_field object:
|
||||
self.remote_field = copy.copy(self.remote_field)
|
||||
|
||||
|
|
@ -207,7 +206,6 @@ class TranslationField:
|
|||
|
||||
# ForeignKey support - rewrite related_name
|
||||
elif not NEW_RELATED_API and self.rel and self.related and not self.rel.is_hidden():
|
||||
|
||||
current = self.related.get_accessor_name()
|
||||
self.rel = copy.copy(self.rel) # Since fields cannot share the same rel object.
|
||||
# self.related doesn't need to be copied, as it will be recreated in
|
||||
|
|
@ -224,7 +222,6 @@ class TranslationField:
|
|||
if hasattr(self.rel.to._meta, '_related_objects_cache'):
|
||||
del self.rel.to._meta._related_objects_cache
|
||||
elif NEW_RELATED_API and self.remote_field and not self.remote_field.is_hidden():
|
||||
|
||||
current = self.remote_field.get_accessor_name()
|
||||
# Since fields cannot share the same rel object:
|
||||
self.remote_field = copy.copy(self.remote_field)
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ def autodiscover():
|
|||
|
||||
mods = [(app_config.name, app_config.module) for app_config in apps.get_app_configs()]
|
||||
|
||||
for (app, mod) in mods:
|
||||
for app, mod in mods:
|
||||
# Attempt to import the app's translation module.
|
||||
module = '%s.translation' % app
|
||||
before_import_registry = copy.copy(translator._registry)
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ import modeltranslation.tests.models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
|
|
|
|||
|
|
@ -383,7 +383,6 @@ class ModeltranslationTest(ModeltranslationTestBase):
|
|||
|
||||
# However, by default FALLBACK_LANGUAGES is set to DEFAULT_LANGUAGE
|
||||
with default_fallback():
|
||||
|
||||
# No change here...
|
||||
assert inst2.title == title_de
|
||||
|
||||
|
|
@ -3013,9 +3012,13 @@ class TestManager(ModeltranslationTestBase):
|
|||
assert obj2['title'] == 'de'
|
||||
|
||||
# Values_list behave similarly
|
||||
assert list(manager.values_list('title', Cast("pk", output_field=CharField()))) == [('en', str(id1))]
|
||||
assert list(manager.values_list('title', Cast("pk", output_field=CharField()))) == [
|
||||
('en', str(id1))
|
||||
]
|
||||
with override('de'):
|
||||
assert list(manager.values_list('title', Cast("pk", output_field=CharField()))) == [('de', str(id1))]
|
||||
assert list(manager.values_list('title', Cast("pk", output_field=CharField()))) == [
|
||||
('de', str(id1))
|
||||
]
|
||||
|
||||
def test_custom_manager(self):
|
||||
"""Test if user-defined manager is still working"""
|
||||
|
|
|
|||
Loading…
Reference in a new issue