title: I want to create a details page with two models for an auction site with django but keep getting FieldError. How do I correct this error?
body: <p>I am creating an ebay like aunction site, the details view page should reflect details from two models.</p>
  <p>One of the models has the details of the current_bid (this is created when creating the listing), there is also the second model that contains new_bids (this is where the users who want to purchase the item can input their bids).</p>
  <p>The issue(s) I'm having is how to put two models in my details view and also if you can confirm my current logic in finding out the highest bid (if this is correct or not).</p>
  <p>MODELS.PY</p>
  <pre><code>class Auction(models.Model):
      ABSTRACT = 'AB'
      MODERN = 'MN'
      ILLUSTRATION = 'IN'
  
      select_category = [
          ('ABSTRACT', 'Abstract'),
          ('MODERN', 'Modern'),
          ('ILLUSTRATION', 'Illustration')
      ]
  
      title = models.CharField(max_length=25)
      description = models.TextField()
      current_bid = models.IntegerField(null=False, blank=False)
      image_url = models.URLField(verbose_name=&quot;URL&quot;, max_length=255, unique=True, null=True, blank=True)
      category = models.CharField(
          choices=select_category,
          max_length=12,
          default=MODERN,
          null=True, blank=True
      )
      created_at = models.DateTimeField(auto_now_add=True)
  
      def __str__(self):
          return self.title
  
      class Meta:
          ordering = ['-created_at']
  
  class Bids(models.Model):
      auction = models.ForeignKey(Auction, on_delete=models.CASCADE, related_name='bidding')
      user = models.ForeignKey(User, on_delete=models.PROTECT, related_name='bidding')
      new_bid = models.DecimalField(max_digits=8, decimal_places=2)
      # new_bid = MoneyField(max_digits=10, decimal_places=2, null=False, blank=False, default_currency='USD', default=0)
      done_at = models.DateTimeField(auto_now_add=True)
  
      class Meta:
          ordering = ['auction', '-new_bid']
  </code></pre>
  <p>FORMS.PY</p>
  <pre><code>class AuctionForm(forms.ModelForm):
      
      class Meta:
          model = Auction
          fields = ['title', 'description', 'current_bid', 'image_url', 'category']
  
  class BidForm(forms.ModelForm):
  
      class Meta:
          model = Bids
          fields = ['new_bid']
          labels = {
              'new_bid': ('Choose your maximum bid'),
          }
  </code></pre>
  <p>VIEWS.PY</p>
  <pre><code>def listing_detail(request, listing_id):
      detail = get_object_or_404(Auction, pk=listing_id)
      if detail == None:
          messages.add_message(request, messages.ERROR, &quot;This is not available&quot;) 
          return HttpResponseRedirect(reverse(&quot;index&quot;))
      bid_queryset = Bids.objects.filter(detail=listing_id).order_by('new_bid').first()
      if bid_queryset == None:
          bid = detail.current_bid
      else:
          bid = bid_queryset.new_bid
      context = {'detail': detail}
      return render(request, 'auctions/details.html', context)
  
  
  @login_required
  def make_bid(request, listing_id):
      bid_item = get_object_or_404(Bids, pk=listing_id)
      each_listing = Auction.objects.get(pk=listing_id)
      try:
          highest_bid = each_listing.bidding.order_by('-new_bid')[0]
      except Bids.DoesNotExist:
          highest_bid = 0
      if request.method == 'POST':
          form = BidForm(request.POST)
          if form.is_valid:
              if form['bidding'] &gt; highest_bid:
                  bidding = form.save()
                  messages.add_message(request, messages.SUCCESS, &quot;Your bid is currently the highest&quot;) 
                  return HttpResponseRedirect(reverse(&quot;index&quot;))
              else:
                  messages.add_message(request, messages.ERROR, &quot;Your bid must be higher than the previous bid&quot;) 
  
      else:
          form = BidForm(initial={'each_listing': each_listing,
                                      'user': request.user,
                                      'amount': highest_bid})
          return render(request, 'auctions/details.html', {'form': form})   
  </code></pre>
  <p>DETAILS.HTML</p>
  <pre><code>        &lt;section&gt;
              &lt;div class=&quot;row container&quot;&gt;
                  &lt;div class=&quot;col-sm-7 pr-5&quot;&gt;
                      {% if detail.image_url %}
                          &lt;img src='{{ detail.image_url }}' alt=&quot;{{ detail.title }}&quot; style=&quot;width:100%&quot;&gt;
                      {% else %}
                          &lt;img src=&quot;https://demofree.sirv.com/nope-not-here.jpg&quot;&gt;
                      {% endif %}  
                 
                  &lt;/div&gt;
                  &lt;div class=&quot;col-sm-5&quot;&gt;
                      &lt;div style=&quot;width: 30rem;&quot;&gt;
                          &lt;div&gt;
                              &lt;h5&gt;{{ detail.title }}&lt;/h5&gt;
                              &lt;hr&gt;
                              &lt;p&gt;{{ detail.description }}&lt;/p&gt;
                              &lt;hr&gt;
                              &lt;p&gt;{{ detail.current_bid }}&lt;/p&gt;
                              &lt;hr&gt;
                              &lt;p&gt;{{ detail.new_bid }}&lt;/p&gt;
                              &lt;hr&gt;
                              &lt;button class=&quot;btn btn-primary btn-block&quot; &gt;Place bid&lt;/button&gt;
                              &lt;button class=&quot;btn-block btn-outline-primary&quot;&gt;Add to watchlist&lt;/button&gt;
                          &lt;/div&gt;
                        &lt;/div&gt;
                  &lt;/div&gt;
  
                  &lt;form action=&quot;{% url 'auctions:listing_detail' listing.id %}&quot; method=&quot;post&quot;&gt;
                      {% csrf_token %}
                      {{form.as_p}}
                      &lt;input type=&quot;submit&quot; value=&quot;Submit&quot;&gt;
                  &lt;/form&gt;
  </code></pre>
  <p>Right now, I'm having this error message</p>
  <pre><code>FieldError at /detail/15/
  Cannot resolve keyword 'detail' into field. Choices are: auction, auction_id, done_at, id, new_bid, user, user_id
  Traceback Switch to copy-and-paste view
  C:\Users\USER\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\handlers\exception.py, line 47, in inner
                  response = get_response(request) …
  Local vars
  C:\Users\USER\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\handlers\base.py, line 181, in _get_response
                  response = wrapped_callback(request, *callback_args, **callback_kwargs) …
  Local vars
  C:\Users\USER\Downloads\commerce\commerce\auctions\views.py, line 95, in listing_detail
      bid_queryset = Bids.objects.filter(detail=listing_id).order_by('new_bid').first() 
  </code></pre>
  <p>URLS.PY</p>
  <pre><code>urlpatterns = [
      path(&quot;&quot;, views.index, name=&quot;index&quot;),
      path(&quot;create/&quot;, views.create_listing, name=&quot;create_listing&quot;),
      path(&quot;detail/&lt;int:listing_id&gt;/&quot;, views.listing_detail, name=&quot;listing_detail&quot;),
      path(&quot;bid/&lt;int:listing_id&gt;/&quot;, views.make_bid, name=&quot;bid&quot;),
  </code></pre>