1
My project is a simple table showing countries, number of covid cases, deaths and recoveries. By Django admin I have already registered two countries and now I want to recover this data and show on the route, but is not showing.
Link to the complete project: https://github.com/PUC-DISCIPLINAS/monitorcoviddjango-monitor-django-guilherme-pedro This is my html file: https://github.com/CunhaGuilhermeBR/html/blob/main/index.html
My model, I’m calling data:
# Create your models here.
class Dados(models.Model):
casos_confirmados = models.IntegerField()
mortes = models.IntegerField()
recuperados = models.IntegerField()
pais = models.CharField(max_length=100)
def __int__(self):
return(self.id)
class Meta:
db_table = 'dados'
And this is my view
@login_required(login_url='/login/')
def list_data(request):
dados = Dados.objects.all()
print(dados.query)
for d in dados:
print(d)
return render(request, 'index.html',{dados: dados})
What it prints is: Data Object (1) Data Object (2) Remembering that I have two registered countries. I wanted to find out what I am doing wrong.
Man, thanks a lot, it worked great. Now in theory what I was doing wrong was how I passed the data to html and how did I iterate into html? Thanks again
– Guilherme Augusto Gomes Cunha
For nothing, anything we are here to try to help. :)
– stack.cardoso