Browse files

fixed an issue with the new double-TranslatedFields detector when having

a ForeignKey from a NON-translated model to a translated model
  • Loading branch information...
1 parent 547b6cf commit 6bed9e9c60b5adb125ad1454c32887f9fa2171b3 @ojii committed Feb 16, 2012
Showing with 13 additions and 2 deletions.
  1. +1 −1 nani/models.py
  2. +12 −1 nani/tests/related.py
View
2 nani/models.py
@@ -114,7 +114,7 @@ def __new__(cls, name, bases, attrs):
continue
if not hasattr(obj.related, 'model'):
continue
- if obj.related.model._meta.shared_model is new_model:
+ if getattr(obj.related.model._meta, 'shared_model', None) is new_model:
if found:
raise ImproperlyConfigured(
"A TranslatableModel can only define one set of "
View
13 nani/tests/related.py
@@ -238,4 +238,15 @@ class ReverseRelated(TranslatableModel):
translated_fields = TranslatedFields(
translated = models.CharField(max_length=1)
)
-
+ def test_issue_22_non_translatable_model(self):
+ class ForwardRelated2(models.Model):
+ shared_field = models.CharField(max_length=255)
+ fk = models.ForeignKey("ReverseRelated2", related_name='rel', null=True)
+
+
+ class ReverseRelated2(TranslatableModel):
+ shared_field = models.CharField(max_length=255)
+
+ translated_fields = TranslatedFields(
+ translated = models.CharField(max_length=1)
+ )

0 comments on commit 6bed9e9

Please sign in to comment.