Fehler:
Code: Select all
Reverse for 'listing' with arguments '('',)' not found. 1 pattern(s) tried: ['listing/(?P[0-9]+)$']
Code: Select all
auctions\views.py, line 229, in closeListing
return render(request, "auctions/closeListing.html", {
< strong>views.py
Code: Select all
def closeListing(request, id):
bids = Bid.objects.filter(bid_item_id=id).order_by('-bid_input')
winner = Bid.objects.filter(bid_item_id=id).latest('bid_input').bidder.id
winner_name = Bid.objects.filter(bid_item_id=id).latest('bid_input').bidder.username
currentHighest = Bid.objects.filter(bid_item_id=id).aggregate(Max('bid_input'))['bid_input__max']
if request.method == "POST":
if bids == 0:
return render(request, "auctions/closeListing.html", {
"bids": bids,
"error": "No bids have been placed on your listing",
})
else:
Listing.objects.filter(id=id).update(status='closed')
Listing.objects.filter(id=id).update(winner=winner)
closed = True
return render(request, "auctions/closeListing.html", {
"bids": bids,
"current": currentHighest,
"winner": winner_name,
"closed": True
})
else:
return render(request, "auctions/closeListing.html", {
"bids": bids
})
Code: Select all
path("listing//close", views.closeListing, name="closelisting")
Code: Select all
{% if request.user.is_authenticated and request.user == listing.lister %}
{% csrf_token %}
{% endif %}