这是我的模型。py
@python_2_unicode_compatible
class TaggedItem(models.Model):
content_type = models.ForeignKey(
ContentType,
related_name=getattr(
settings, 'USER_TAGS_RELATED_NAME', 'user_tags_tagged_items', on_delete=models.CASCADE),
)
object_id = models.PositiveIntegerField()
content_object = GenericForeignKey('content_type', 'object_id')
user_tags = models.ManyToManyField(
'user_tags.UserTag',
verbose_name=_('User tag'),
)
def __str__(self):
return str(self.content_object)