You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
class Industry(TranslationModel):
name = models.CharField(max_length=255)
profession_set = models.ManyToManyField(
'Profession',
through='IndustryProfession',
)
def __str__(self):
return self.name
class Meta:
translatable_fields = ('name',)
Getting a shell exception:
In [5]: Industry.objects.language('fr').filter(name='Armement')
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
<ipython-input-5-6ae5df24159f> in <module>
----> 1 Industry.objects.language('fr').filter(name='Armement')
~/.local/lib/python3.8/site-packages/nece/managers.py in filter(self, *args, **kwargs)
80 def filter(self, *args, **kwargs):
81 if not self.is_default_language(self._language_code):
---> 82 for key, value in kwargs.items():
83 if key.split('__')[0] in self.model._meta.translatable_fields:
84 del kwargs[key]
RuntimeError: dictionary keys changed during iteration
Not sure what I'm doing wrong, also got some weird results here:
In [14]: Industry.objects.filter(name='Armament').first().translations
Out[14]: {'name': {'en': 'Armament', 'fr': 'Armement'}}
In [15]: test = Industry.objects.filter(name='Armament').first()
In [16]: test.language('fr')
Out[16]: <Industry: Armament>
In [17]: test.name
Out[17]: 'Armament' <-------------- not the fr translation
The text was updated successfully, but these errors were encountered:
With this code:
Getting a shell exception:
Not sure what I'm doing wrong, also got some weird results here:
The text was updated successfully, but these errors were encountered: