Commit ae115b53 by Carl Meyer

fix custom PKs

parent 6781567d
...@@ -102,7 +102,7 @@ class TaggableManager(object): ...@@ -102,7 +102,7 @@ class TaggableManager(object):
def m2m_reverse_name(self): def m2m_reverse_name(self):
if self.use_gfk: if self.use_gfk:
return "id" return "id"
return self.through._meta.get_field('content_object').rel.to._meta.pk.column return self.through._meta.pk.column
def m2m_column_name(self): def m2m_column_name(self):
if self.use_gfk: if self.use_gfk:
......
...@@ -70,7 +70,8 @@ class TaggableManagerTestCase(BaseTaggingTest): ...@@ -70,7 +70,8 @@ class TaggableManagerTestCase(BaseTaggingTest):
apple.delete() apple.delete()
self.assert_tags_equal(self.food_model.tags.all(), ["green"]) self.assert_tags_equal(self.food_model.tags.all(), ["green"])
def test_require_pk(self):
f = self.food_model() f = self.food_model()
with self.assert_raises(ValueError): with self.assert_raises(ValueError):
f.tags.all() f.tags.all()
...@@ -178,6 +179,10 @@ class TaggableManagerCustomPKTestCase(TaggableManagerTestCase): ...@@ -178,6 +179,10 @@ class TaggableManagerCustomPKTestCase(TaggableManagerTestCase):
housepet_model = CustomPKHousePet housepet_model = CustomPKHousePet
taggeditem_model = TaggedCustomPKPet taggeditem_model = TaggedCustomPKPet
def test_require_pk(self):
# XXX with a charfield pk, pk is never None, so taggit has no
# way to tell if the instance is saved or not
pass
class TaggableFormTestCase(BaseTaggingTest): class TaggableFormTestCase(BaseTaggingTest):
form_class = FoodForm form_class = FoodForm
......
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