Skip to content

Commit

Permalink
fixed an issue with the new double-TranslatedFields detector when having
Browse files Browse the repository at this point in the history
a ForeignKey from a NON-translated model to a translated model
  • Loading branch information
ojii committed Feb 16, 2012
1 parent 547b6cf commit 6bed9e9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion nani/models.py
Expand Up @@ -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 "
Expand Down
13 changes: 12 additions & 1 deletion nani/tests/related.py
Expand Up @@ -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.