I am attempting to follow this tutorial to have a hierarchical tag structure. http://tentacles.posterous.com/django-hierarchical-tags-with-taggit-and-tree
My code looks like this:
----models.py---
from taggit.models import TagBase, ItemBase
from taggit.managers import TaggableManager
from treebeard.mp_tree import MP_Node
class HierarchicalTag(TagBase, MP_Node):
node_order_by = [ 'name' ]
class TaggedAlbum(ItemBase):
aid = models.ForeignKey('Album')
tag = models.ForeignKey('HierarchicalTag', related_name='tags')
class Album(ItemBase):
name = models.CharField('Album Name',max_length=45, null=False, blank=False)
description = models.CharField('Album Description',max_length=255, null=False, blank=False)
tags = TaggableManager(through=TaggedAlbum, blank=True)
Now if I run this code, I get a stack trace:
>>> from photos.models import *
>>> a1 = Album(name='a1',description='desc')
>>> a1.save()
>>> a1
<Album: a1>
>>> a1.tags
<taggit.managers._TaggableManager object at 0x02E15390>
>>> a1.tags.all()
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "C:\Python27\lib\site-packages\django\db\models\manager.py", line 116, in all
return self.get_query_set()
File "C:\DEV\PM\taggit\managers.py", line 150, in get_query_set
return self.through.tags_for(self.model, self.instance)
File "C:\DEV\PM\photos\models.py", line 24, in tags_for
'%s__content_object' % cls.tag_relname(): instance
File "C:\Python27\lib\site-packages\django\db\models\manager.py", line 143, in filter
return self.get_query_set().filter(*args, **kwargs)
File "C:\Python27\lib\site-packages\django\db\models\query.py", line 621, in filter
return self._filter_or_exclude(False, *args, **kwargs)
File "C:\Python27\lib\site-packages\django\db\models\query.py", line 639, in _filter_or_exclude
clone.query.add_q(Q(*args, **kwargs))
File "C:\Python27\lib\site-packages\django\db\models\sql\query.py", line 1250, in add_q
can_reuse=used_aliases, force_having=force_having)
File "C:\Python27\lib\site-packages\django\db\models\sql\query.py", line 1122, in add_filter
process_extras=process_extras)
File "C:\Python27\lib\site-packages\django\db\models\sql\query.py", line 1316, in setup_joins
"Choices are: %s" % (name, ", ".join(names)))
FieldError: Cannot resolve keyword 'content_object' into field. Choices are: aid, id, tag
>>>
What does this 'content_object' mean? How do I fix it?