Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django ValueError - not enough values to unpack (expected 2, got 1)

Tags:

django

Getting the error in the title when I try to go on my listing_public page, can't figure out why.

views.py

def listing_public(request, pk):

    listing = get_object_or_404(BuyerListing, pk)

    return render (
        request,
        'listing_public.html',
        context={'listing':listing}
    )

urls.py

url(r'^listing/(?P<pk>\d+)/$', views.listing_public, name='listing_public'),

Template Tags

{% url 'listing_public' pk=listing.pk %}

This is the only other question on Stack Overflow I found regarding this error, but the sole answer didn't solve my problem. Here is the traceback.

like image 423
Valachio Avatar asked Nov 08 '17 20:11

Valachio


1 Answers

See if specifying the argument changes anything

listing = get_object_or_404(BuyerListing, pk=pk)
like image 101
NS0 Avatar answered Nov 13 '22 03:11

NS0