I currently have a bunch of old comments, that I need to migrate to django.contrib.comment
and the plan was to manually create instances of Comment and then save it as follows:
# assume some_content is NOT a django Comment instance, but in some proprietary format
# assume the model I'm attaching the comment to is called Blog i.e models.Blog
c = Comment()
c.user = user
c.submit_date = some_comment.comment_date_time
c.comment = some_comment.comment
...
c.save()
The main issue is the missing information found in class BaseCommentAbstractModel
found in django.contrib.comment.model
. Specifically the three fields:
BaseCommentAbstractModel(models.Model):
# Content-object field
content_type = models.ForeignKey(ContentType,
verbose_name=_('content type'),
related_name="content_type_set_for_%(class)s")
object_pk = models.TextField(_('object ID'))
content_object = generic.GenericForeignKey(ct_field="content_type", fk_field="object_pk")
I read the documentation and, to the best of my ability, the source, but it wasn't detailed enough. How do I properly specify those fields from the model object (model.Blog)?
Maybe there is a method somewhere that accepts model object and the content of the comment to add?