title: How to stop the user from being able to submit all other Django forms once a specific form is submitted?
body: <p>I am trying to create an e-commerce site (CS50 Project 2) that allows its users to make comments, bids, and add listing items to their watchlists. I want the user who created the listing to be able to close the listing so that the winner (highest bidder) is displayed and no other of the forms will work (I also want to delete the listing from the watchlist). Currently, when the user who created the listing closes the listing, it saves (because it is a Django model), but the forms do not disappear, the listing does not delete off the watchlist, and the messages do not appear. How do I fix this?  (I think it has to do with the if statement.)</p>
  <p>views.py</p>
  <pre><code>@login_required(login_url='login')
  def listing(request, id):
      #gets listing
      listing = get_object_or_404(Listings.objects, pk=id)
      #code for comment and bid forms
      listing_price = listing.bid
      sellar = listing.user
      comment_obj = Comments.objects.filter(listing=listing)
      #types of forms
      comment_form = CommentForm()
      bid_form = BidsForm()
      #watchlist_form = WatchListForm()
      #closelisting_form = CloseListingForm()
     
      #close listing code
      if sellar == request.user:
          closeListingButton = True
      else: 
          closeListingButton = False
      closeListing = ''
      try:
          has_closed = get_object_or_404(CloseListing, Q(
              user=request.user) &amp; Q(listing=listing))
      except:
          has_closed = False
      if has_closed:
          closeListing = False
      else: 
          closeListing = True
      
     #watchlist code
      add_or_remove_watchlist = ''
      try:
          has_watchlists = get_object_or_404(WatchList, Q(
              user=request.user) &amp; Q(listing=listing))
          print('--------------------------')
          print(has_watchlists)
          print('--------------------------')
      except:
          has_watchlists = False
  
      if has_watchlists:
          add_or_remove_watchlist = True
      else:
          print('it will from remove')
          add_or_remove_watchlist = False
  
      #code for the bid form
      bid_obj = Bids.objects.filter(listing=listing)
      other_bids = bid_obj.all()
      max_bid =0
      for bid in other_bids:
          if listing.bid &gt; max_bid:
              max_bid = listing.bid
  
       #checks if request method is post for all the forms
      if request.method == &quot;POST&quot;:
          #forms
          comment_form = CommentForm(request.POST)
          bid_form = BidsForm(request.POST)
  
          #watchlist code
          if request.POST.get('add'):
              WatchList.objects.create(user=request.user, listing=listing)
              add_or_remove_watchlist = False
          elif request.POST.get('remove'):
              add_or_remove_watchlist = True
              has_watchlists.delete()
  
          #close listing code
          if request.POST.get('close'):
              CloseListing.objects.create(user=request.user, listings=listing)
              closeListing = True
              closeListingButton = False
          else:
              closeListing = False
  
          #checks if comment form is valid
          if comment_form.is_valid():
              comment = comment_form.save(commit=False)
              comment.listing = listing
              comment.user = request.user
              comment.save()
          else:
              return redirect('listing', id=id)
  
          #checks if bid form is valid
          if bid_form.is_valid():
              print(&quot;bid form is valid&quot;)
              new_bid = bid_form.cleaned_data.get(&quot;bid&quot;)
              if (new_bid &gt;= listing_price) and (new_bid &gt; max_bid):
                  bid = bid_form.save(commit=False)
                  bid.listing = listing
                  bid.user = request.user
                  bid.save()
                  print(&quot;bid form is saving&quot;)
              else:
                  print(bid_form.errors)
                  print(&quot;bid form is not saving&quot;)
                  return render(request, &quot;auctions/listing.html&quot;,{
                      &quot;auction_listing&quot;: listing,
                      &quot;form&quot;: comment_form,
                      &quot;comments&quot;: comment_obj,
                      &quot;bidForm&quot;: bid_form,
                      &quot;bids&quot;: bid_obj,
                      &quot;message&quot;: &quot;Your bid needs to be equal or greater than the listing price and greater than any other bids.&quot;
                  })
          else:
              print(bid_form.errors)
              return redirect('listing', id=id)
  
          #what happens if listing is closed
          if closeListing == True:
              closeListingButton = False
              has_watchlists.delete()
              winner = max_bid.user
              return render(request, &quot;auctions/listing.html&quot;,{
                          &quot;auction_listing&quot;: listing,
                          &quot;comments&quot;: comment_obj,
                          &quot;bids&quot;: bid_obj,
                          &quot;closeListingButton&quot;: closeListingButton,
                          &quot;closeListing&quot;: closeListing,
                          &quot;closedMessage&quot;: &quot;This listing is closed.&quot;,
                          &quot;winner&quot;: winner
              })
          else: 
              return redirect('listing', id=id)
         
      return render(request, &quot;auctions/listing.html&quot;,{
          &quot;auction_listing&quot;: listing,
          &quot;form&quot;: comment_form,
          &quot;comments&quot;: comment_obj,
          &quot;bidForm&quot;: bid_form,
          &quot;bids&quot;: bid_obj,
          &quot;watchlist&quot;: add_or_remove_watchlist,
          &quot;closeListingButton&quot;: closeListingButton
      })
  
  listing.html
  </code></pre>
  <pre><code>&lt;!--close listing code--&gt;
      {% if closeListing == True %}
          &lt;div&gt;{{ closedMessage }}
              &lt;br&gt;
              {{ winner }} has won the auction!
          &lt;/div&gt;
      {% endif %}
  
      &lt;form action = &quot;{% url 'listing' auction_listing.id %}&quot; method = &quot;POST&quot;&gt;
          {% csrf_token %}
          {% if closeListingButton == True %}
              &lt;input type = &quot;submit&quot; value = &quot;Close Listing&quot; name = &quot;close&quot;&gt;
              &lt;br&gt;
              &lt;br&gt;
          {% endif %}
  
      &lt;!--watchlist form--&gt;
      {% if watchlist_message %}
          &lt;div&gt;{{ watchlist_message }}&lt;/div&gt;
      {% endif %}
  
      &lt;form action = &quot;{% url 'listing' auction_listing.id %}&quot; method = &quot;POST&quot;&gt;
          {% csrf_token %}
          {% if watchlist == True %}
              &lt;input type=&quot;submit&quot; value='Remove from Watchlist' name='remove'&gt;
          {% else %}
              &lt;input type=&quot;submit&quot; value='Add to Watchlist' name='add'&gt;
          {% endif %}
      &lt;/form&gt;
  
      &lt;br&gt;
      &lt;!--bid form--&gt;
      {% if message %}
          &lt;div&gt;{{ message }}&lt;/div&gt;
      {% endif %}
  
      &lt;form action = &quot;{% url 'listing' auction_listing.id %}&quot; method = &quot;POST&quot; name = &quot;newBid&quot;&gt;
          {% csrf_token %}
          {{ bidForm }}
          {{ bidForm.errors }}
          &lt;input type = &quot;submit&quot; value = &quot;Place Bid&quot;&gt;
      &lt;/form&gt;
      {{ bidForm.errors }}
  
      &lt;br&gt;
      {% for bid in bids %}
          &lt;h6&gt;${{ bid.bid }} &lt;div style = &quot;font-family: monospace;&quot;&gt;Bid By: {{ bid.user }}&lt;/div&gt;&lt;/h6&gt;
      {% endfor %} 
  
      &lt;!--comment form--&gt;
      &lt;br&gt;
      &lt;form action = &quot;{% url 'listing' auction_listing.id %}&quot; method = &quot;POST&quot;&gt;
          {% csrf_token %}
          {{ form }}
          &lt;input type = &quot;submit&quot; value = &quot;Add Comment&quot;&gt;
      &lt;/form&gt;
  
      &lt;br&gt;
      {% for comment in comments %}
          &lt;h6&gt; {{ comment.comment }} &lt;div style = &quot;font-family: monospace;&quot;&gt;Comment By: {{ comment.user }}&lt;/div&gt;&lt;/h6&gt;
      {% endfor %}
  </code></pre>
  <pre><code></code></pre>