Commit f3bc9db0 by Collin Anderson Committed by Florian Apolloner

fix AttributeError: 'TaggableRel' object has no attribute 'to'

parent 8c6fc806
......@@ -33,7 +33,8 @@ def _model_name(model):
class TaggableRel(ManyToManyRel):
def __init__(self, field, related_name, through):
def __init__(self, field, related_name, through, to=None):
self.to = to
self.related_name = related_name
self.limit_choices_to = {}
self.symmetrical = True
......@@ -224,7 +225,7 @@ class TaggableManager(RelatedField, Field):
manager=_TaggableManager):
Field.__init__(self, verbose_name=verbose_name, help_text=help_text, blank=blank, null=True, serialize=False)
self.through = through or TaggedItem
self.rel = TaggableRel(self, related_name, self.through)
self.rel = TaggableRel(self, related_name, self.through, to=to)
self.swappable = False
self.manager = manager
# NOTE: `to` is ignored, only used via `deconstruct`.
......
......@@ -326,6 +326,7 @@ class TaggableManagerTestCase(BaseTaggingTestCase):
# Check if tag field, which simulates m2m, has django-like api.
field = self.food_model._meta.get_field('tags')
self.assertTrue(hasattr(field, 'rel'))
self.assertTrue(hasattr(field.rel, 'to'))
self.assertTrue(hasattr(field, 'related'))
self.assertEqual(self.food_model, field.related.model)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment