Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23276

Reverse for '' with arguments '('',)' not found. 1 pattern(s) tried

$
0
0

I'm getting this error anytime I click on this submit button on my listing page. I've looked through the typical places that this kind of error is triggered by but I can't see what I'm doing wrong here.

Error:

Reverse for 'listing' with arguments '('',)' not found. 1 pattern(s) tried: ['listing/(?P<id>[0-9]+)$']

and further down on the page, on the traceback this line is highlighted as below. For clarity, it is highlighting the 2nd return render in that view.

auctions\views.py, line 229, in closeListing            return render(request, "auctions/closeListing.html", {

I know that in my views and urls I pass the argument of id but then on the template I pass the argument of listing.id but this has been working throughout my project for some reason but just not working here. I actually just tried to change all the arguments in views and urls to listing_id to match the listing.id in the template and this produced the exact same error so I'm really lost.

views.py

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        })

urls.py

path("listing/<int:id>/close", views.closeListing, name="closelisting")

listingPage.html

{% if request.user.is_authenticated and request.user == listing.lister %}<div><form action="{% url 'closelisting' listing.id %}" method="post">        {% csrf_token %}<input type=submit value="Close Listing"></form></div>{% endif %}

Viewing all articles
Browse latest Browse all 23276

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>