[Django]-Why am I getting this error 'WSGIRequest' object has no attribute 'kwargs'?

3👍

Because indeed request doesn’t have any attribute called kwargs.

I see you have a form called CommentForm that is being submitted using the HTTP POST method. If that form actually has a field named pk, then you can get the value of it by doing:

form.instance.post_id = self.request.POST['pk']

Leave a comment