I'm using django-taggit to tag my to do records.
class Action(models.Model):
name = models.CharField("Action Name", max_length=200)
complete = models.BooleanField(default=False, verbose_name="Complete?")
tags = TaggableManager()
I'm trying to make an exact copy of a records, down to the tags that are associated with the task.
new_obj = deepcopy(self)
new_obj.id = None
new_obj.save()
After running this code, the copy is exact except that there are no affiliated tags. How can I copy all of the tags from "self" to new_obj?
Instead of adding the tags to the object:
new_obj.tags.add(tag)
I added the new object to the Tag:
for tag in self.tags.all():
tag_object = TaggedItem(content_object = new_obj, tag = tag)
tag_object.save()