title: Django Error: ValueError at /new_bid/1 Cannot assign "1": "Bid.listingid" must be a "Listings" instance
body: <p>I am getting the error: ValueError at /new_bid/1
  Cannot assign &quot;1&quot;: &quot;Bid.listingid&quot; must be a &quot;Listings&quot; instance.&quot;</p>
  <p>I am still learning about Foreign Keys so I may have used it wrong? I'm also using 'listingid' in both the models 'Listings' and 'Bid.' I'm wondering if this is part of the issue, but it makes sense to have both to me.</p>
  <p>I am just learning about how 'self' works also, so I think part of the problem is in the Listings model at the very bottom:</p>
  <p>In the Listings model if I do: return self.last_bid I get the error &quot;'&gt;' not supported between instances of 'int' and 'Bid'&quot; and if I keep it as is now, I get the error in the title of this Stack Overflow post.</p>
  <p>Any help is appreciated, I'm having trouble understanding the error.</p>
  <p>views.py</p>
  <pre><code>def new_bid(request, listingid):
      if request.method == &quot;POST&quot;:
          listing = Listings.objects.get(pk=listingid)
          response = redirect(&quot;listingpage&quot;, listingid=listingid)
          try:
              bid = int(request.POST[&quot;bid&quot;])
          except ValueError:
              response.set_cookie(
                  &quot;message&quot;, &quot;Please input something before submitting the bid&quot;, max_age=3
              )
              return response
          if bid &gt; listing.current_price():
              response.set_cookie(&quot;message&quot;, &quot;Your bid was accepted&quot;, max_age=3)
              Bid.objects.create(bid=bid, listingid=listingid, user=request.user)
          else:
              response.set_cookie(
                  &quot;message&quot;, &quot;Your bid should be higher than the current bid&quot;, max_age=3
              )
          return response
      else:
          return redirect(&quot;index&quot;)
  </code></pre>
  <p>models.py</p>
  <pre><code>class Bid(models.Model):
      user = models.CharField(max_length=64)
      title = models.CharField(max_length=64)
      bid = models.IntegerField(blank=True)
      listingid = models.ForeignKey('Listings', on_delete=models.CASCADE, related_name='listing_for_bid')
  
  class Listings(models.Model):
      listingid = models.IntegerField(blank=True, null=True)
      description = models.TextField(max_length=250)
      starting_bid = models.IntegerField()
      bids = models.ManyToManyField('Bid', related_name='bids_in_the_auction', blank=True)
      last_bid = models.ForeignKey('Bid', on_delete=models.CASCADE, related_name='last_bid_for_the_auction', blank=True,
                               null=True)
    def current_price(self):
      return self.starting_bid
  </code></pre>