-1
我VIEW.PY文件是:視圖music.views.detail沒有返回HttpResponse對象。它返回無不是
from django.http import Http404
from django.shortcuts import render
from .models import Album
def index(request):
all_albums = Album.objects.all()
return render(request, 'music/index.html', {'all_albums': all_albums})
def detail(request, album_id):
try:
album = Album.objects.get(pk=album_id)
except Album.DoesNotExist:
raise Http404("Album does not exist")
return render(request, 'music/detail.html', {'album': album})'
DETAIL.HTML文件是:
{{ album }}
我得到錯誤:
The view music.views.detail didn't return an HttpResponse object. It returned None instead
請正確縮進的代碼,以便意思很明顯 – kdopen
縮進我的代碼需要和錯誤被刪除 –
無正確的縮進,這個問題可以關閉爲「不清楚」或「無MCVE」。 – halfer