title: Django - If statement with request.user
body: <p>I have a problem with an if-statement. I just want to check on a page if the user who requests the listing page is the same one as the user who won the listing on that page.</p>
  <p>My view looks like this:</p>
  <pre><code>def show_closed_listing(request, listing_id):
      closed_listing = InactiveListing.objects.get(id=listing_id)
      field_name = &quot;winning_user&quot;
      winning_user = getattr(closed_listing,field_name)
      message = False
      print(request.user)
      print(winning_user)
      if request.user == winning_user:
          print(&quot;This is good&quot;)
          message = &quot;You have won this listing!&quot;
      else:
          print(&quot;Not good&quot;)
      return render(request, &quot;auctions/closed_listing.html&quot;, {
          &quot;closed_listing&quot; : closed_listing,
          &quot;message&quot; : message
      })
  </code></pre>
  <p>When I visit a page, signed in as Test2, when Test2 has won the listing, my terminal shows as follows:</p>
  <ul>
  <li>Test2</li>
  <li>Test2</li>
  <li>Not good</li>
  </ul>
  <p><a href="https://i.stack.imgur.com/uUKUk.png" rel="nofollow noreferrer">As also can be seen here</a></p>
  <p><strong>I don't get why request.user and winning_user look the same, but the if-statement is false?</strong></p>
  <p>If needed, here is my model:</p>
  <pre><code>class InactiveListing(models.Model):
      title = models.CharField(max_length=64)
      description = models.CharField(max_length=512, default=&quot;&quot;)
      winning_user = models.CharField(max_length=128)
      winning_price = models.DecimalField(max_digits=6, decimal_places=2, default=0.01)
      def __str__(self):
          return self.title
  </code></pre>