gpt4 book ai didi

python - 使用参数 'results' ', '(' { )' and keyword arguments ' polls/(?P[0-9]+)/results/$'] 反转 }' not found. 1 pattern(s) tried: ['

转载 作者:太空宇宙 更新时间:2023-11-03 16:00:30 25 4
gpt4 key购买 nike

我尝试为相册创建 URL,但感到沮丧

所以我收到了这个错误(我是编程新手)

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

在这条线上

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

这是view.py文件

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

这是 url.py 文件

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'),
]

最佳答案

它似乎是空的,因为您正在使用专辑,而它只是专辑。尝试使用:

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

而不是:

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

(抱歉我的英语)

关于python - 使用参数 'results' ', '(' { )' and keyword arguments ' polls/(?P<Album_id>[0-9]+)/results/$'] 反转 }' not found. 1 pattern(s) tried: [',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40364645/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com