I’am trying to display data from the database file which has the value Age : 50 but
i alway get “Age object” displayed in the html. I’m very new too Django.
Here is the code
//base.HTML displays :
Age object
//base.html code :
<body>
{{ obj }}
</body>
//views.py :
def home(request):
obj = Age.objects.all()
return render_to_response("base.html",{'obj': obj})
//models.py
class Age(models.Model):
age = models.CharField(max_length=100)
simply
objis an array of objects, you have to print the attribute of the object.If you want to show only one
age(the first) you have to do: