ThisGuy
ThisGuy

Reputation: 13

Reverse for 'results' with arguments '('',)' and keyword arguments '{}' not found. 1 pattern(s) tried: ['polls/(?P<Album_id>[0-9]+)/results/$']

im trying to create an URL's for albums but getting frustrated

so im getting this error(im new to programming)

Reverse for 'results' with arguments '('',)' and keyword arguments '{}' not found. 1 pattern(s) tried: ['polls/(?P<Album_id>[0-9]+)/results/$']

on this line

<h1><a href="{% url 'polls:results' Album.id %}">{{ album.AlbumTitle }}</a></h1>

heres the view.py file

from django.shortcuts import get_object_or_404, render
from django.http import HttpResponse
from django.http import Http404
from django.template import loader
from django.shortcuts import get_object_or_404, render

from .models import Artist


def index(request):
    latest_Artist_list = Artist.objects.order_by('id')[:5]
    context = {'latest_Artist_list': latest_Artist_list,}
    return render(request, 'polls/index.html', context)


def detail(request, Artist_id):
    global Artist
    artist = get_object_or_404(Artist, pk=Artist_id)         #kazkodel mazoji
    return render(request, 'polls/detail.html', {'Artist': artist}) #kazkodel mazoji

def results(request, Album_id):
    #global Album
    album = get_object_or_404(Album, pk=Album_id)
    return render(request, 'polls/results.html', {'Album': album})

heres the url.py file

from django.conf.urls import url

from . import views

app_name = 'polls'

urlpatterns = [
    url(r'^$', views.index, name='index'),
    url(r'^(?P<Artist_id>[0-9]+)/$', views.detail, name='detail'),
    url(r'^(?P<Album_id>[0-9]+)/results/$', views.results, name='results'),
]

Upvotes: 1

Views: 84

Answers (1)

Genarito
Genarito

Reputation: 3433

It seems to be empty, because you're using Album and It's just album. Try using:

<a href="{% url 'polls:results' album.id %}">

Instead of:

<a href="{% url 'polls:results' Album.id %}">

(Sorry about my english)

Upvotes: 1

Related Questions