im tryng to export data from database to display it on my django server ,,im still new to django ,so i have been following some tutorials, i did exactly what’s on the tutorial and im still getting an error that says “cannot access local variable ‘Album’ where it is not associated with a value”,im stuck i dont even know where im getting it wrong.
views.py
from django.http import HttpResponse
from .models import Album
def index(request):
all_albums = Album.objects.all()
html = ”
for Album in all_albums:
path = ‘/music/’ + str(album.id) + ‘/’
html += ‘< a href=”‘ + path + ‘”>’ + album.album_title + ”
return HttpResponse(html)
def detail(request, album_id):
return HttpResponse(“
Details for Album id:” + str(album_id) + “
“)
Gloria Matope is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.