When I read the source code, I find the function use pk
to as keyword to select data:
def detail(request, album_id):
try:
album = Album.objects.filter(pk=album_id)
except Album.DoesNotExist:
raise Http404("Album does not exist")
context = {
"album":album,
}
return render(request, "music/detail.html", context)
I am used to use id
:
album = Album.objects.filter(id=album_id)
So, is there somewhere different between them?