title: No reverse match error. Reverse for 'user-profile' with arguments '('',)' not found
body: <p>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.</p>
  <p>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?</p>
  <p>Views.py:</p>
  <pre><code>def createMessage(request,pk):
  recipient = Profile.objects.get(id=pk)
  form = MessageForm()
  
  try:
      sender = request.user.profile
  except:
      sender = None 
  
  if request.method == 'POST':
      form = MessageForm(request.POST)
      if form.is_valid():
          message = form.save(commit=False)
          message.sender = sender
          message.recipient = recipient
  
          if sender:
              message.name = sender.name
              message.email = sender.email
          message.save()
  
          messages.success(request, 'Your message was successfully sent!')
          return redirect('user-profile', pk=recipient.id)
  
  context = {'recipient': recipient, 'form': form}
  return render(request, 'users/message_form.html', context)
  </code></pre>
  <p>Models.py:</p>
  <pre><code>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=&quot;messages&quot;)
  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']
  </code></pre>
  <p>Message.html:</p>
  <pre><code>&lt;a href=&quot;{% url 'inbox' %}&quot;&gt;
            &lt;h2&gt;
              &lt;span class=&quot;badge bg-primary&quot;&gt; &lt;i class=&quot;fas fa-arrow-circle-left&quot;&gt;&lt;/i&gt;&lt;/span&gt;
            &lt;/h2&gt;
          &lt;/a&gt;
            &lt;h3 class=&quot;text-center&quot;&gt;{{message.subject}}&lt;/h3&gt;
            &lt;a class=&quot;text-decoration-none&quot; href=&quot;{% url 'user-profile' message.sender.id %}&quot;&gt;{{message.name}}&lt;/a&gt;
            &lt;p&gt;{{message.created}}&lt;/p&gt;
            &lt;div&gt;
              {{message.body|linebreaksbr}}
  
            &lt;/div&gt;
  </code></pre>
  <p>urls.py</p>
  <pre><code>    path('inbox/', views.inbox, name=&quot;inbox&quot;),
      path('message/&lt;str:pk&gt;/', views.viewMessage, name=&quot;message&quot;),
      path('create-message/&lt;str:pk&gt;/',views.createMessage, name= 
      &quot;create-message&quot;),
  </code></pre>