django calls the "listing" function even though I told it to use the "watchlist" function when handling the request which arises when going to the .../watchlist url. I can't find the problem. Here is the error:
File "/home/simon/Dokumente/cs50WebProgramming/commerce/auctions/views.py", line 103, in listing
listing_obj = AuctionListing.objects.get(id=int(listing_id))
ValueError: invalid literal for int() with base 10: 'watchlist'
urls.py
urlpatterns = [
path("", views.index, name="index"),
path("login", views.login_view, name="login"),
path("logout", views.logout_view, name="logout"),
path("register", views.register, name="register"),
path("create", views.create_listing, name="create"),
path("after_create", views.after_create, name="after_create"),
path("<str:listing_id>", views.listing, name="listing"),
path("<str:listing_id>/bid", views.after_bid, name="after_bid"),
path("watchlist", views.watchlist, name="watchlist")
]
views.py
def listing(request, listing_id):
listing_obj = AuctionListing.objects.get(id=int(listing_id))
return render(request, "auctions/listing.html", {
"listing": listing_obj
})
def watchlist(request):
return render(request, "auctions/watchlist.html")