Answer the question
In order to leave comments, you need to log in
How to output model data to Django template?
Good afternoon. I'm new to django, so I'm asking for help from the experts.
There are 2 models
class Musican(models.Model):
band = models.CharField(max_length=10,null=True)
albums = models.CharField(max_length=100)
def __str__(self):
"""
String for representing the Model object.
"""
return self.albums
class Soung(models.Model):
albums = models.ForeignKey(Musican,on_delete=models.CASCADE)
soungs = models.CharField(max_length=100)
def __str__(self):
return self.soungs
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question