[Answered ]-ValueError: Cannot assign "15": "Comment.post" must be a "Post" instance

1👍

You are trying to assign a string to form.instance.post, which is supposed to be a Post instance:

form.instance.post = self.kwargs['pk']

Try something like

form.instance.post = Post.objects.get(pk=int(self.kwargs['pk']))
👤Selcuk

Leave a comment