def post(self, request, *args, **kwargs):
    form = self.request.POST
    profile = Profile.objects.get(user=self.request.user)
    message_for = Profile.objects.get(id=self.kwargs['pk'])
    if form['message']:
        message = Message(from_user=profile, to_user=message_for, message=form['message'])
        message.save()
        messages.success(request, 'Message was sent')
    return HttpResponseRedirect(reverse('profiles:sentmessages'))
def post(self, request, *args, **kwargs):
    form = self.request.POST
    profile = Profile.objects.get(user=self.request.user)
    message_for = Profile.objects.get(id=self.kwargs['pk'])
    if form['message']:
        message = Message(from_user=profile, to_user=message_for, message=form['message'])
        message.save()
        messages.success(request, 'Message was sent')
    return HttpResponseRedirect(reverse('profiles:sentmessages'))