No reverse match error. Reverse for 'user-profile' with arguments '('',)' not found

I have created a messaging function on my website where logged in and guest users can send messages to other users. I have created an inbox for the logged in users to store these messages. When opening up a message from a guest (someone who doesn't have an account) I get an error: Reverse for 'user-profile' with arguments '('',)' not found.

Based on my digging on the web I think this may be due to the fact that the guest user doesnt have a name attached? Could this be it and how would I fix it?

def createMessage(request,pk):
recipient = Profile.objects.get(id=pk)
form = MessageForm()

    sender = request.user.profile
    sender = None 

if request.method == 'POST':
    form = MessageForm(request.POST)
    if form.is_valid():
        message =
        message.sender = sender
        message.recipient = recipient

        if sender:

        messages.success(request, 'Your message was successfully sent!')
        return redirect('user-profile',

context = {'recipient': recipient, 'form': form}
return render(request, 'users/message_form.html', context)

class Message(models.Model):
sender = models.ForeignKey(Profile, on_delete=models.SET_NULL, null=True, blank=True)
recipient = models.ForeignKey(Profile, on_delete=models.SET_NULL, null=True, blank=True, related_name="messages")
name = models.CharField(max_length=200, null=True, blank=True)
email = models.EmailField(max_length=200, null=True, blank=True)
subject = models.CharField(max_length=200, null=True, blank=True)
body = models.TextField()
is_read = models.BooleanField(default=False, null=True)
created = models.DateTimeField(auto_now_add=True)
id = models.UUIDField(default=uuid.uuid4, unique=True, primary_key=True, editable=False)

def __str__ (self):
    return self.subject

class Meta:
    ordering = ['is_read', '-created']


<a href="{% url 'inbox' %}">
            <span class="badge bg-primary"> <i class="fas fa-arrow-circle-left"></i></span>
          <h3 class="text-center">{{message.subject}}</h3>
          <a class="text-decoration-none" href="{% url 'user-profile' %}">{{}}</a>


Answers: 0