i have 2 models but i want to show name of artist in my output
class Musician(models.Model):
name = models.CharField(max_length=50)
instrument = models.CharField(max_length=100)
class Album(models.Model):
name = models.CharField(max_length=100)
artist = models.ForeignKey(Musician, on_delete=models.CASCADE)
num_stars = models.IntegerField()
i want to show artist name by HttpResponce funcction
class Musician_list(View):
def get(self, request):
persons = Album.objects.all().values_list("artist__name").order_by("artist__name")
return HttpResponse(persons)
but this code dont show any things please help me.