I have created model, write views, and urls and html template file but can't show data when doing. If you know the reason please help me? this is 3 file in django project models.py
# from django.contrib.auth.models import User
from django.contrib.auth.models import User
from django.db import models
# from rest_framework.authtoken.admin import User
from schedule import settings
class GiaoVien(models.Model):
madotxep = models.ForeignKey(DotXep, on_delete=models.CASCADE)
hodem = models.CharField(default='', max_length=50)
ten = models.CharField(default='', max_length=20)
viettat = models.CharField(default='', max_length=20)
nhomgv = models.CharField(default='', max_length=20)
mamau = models.IntegerField(default=0)
stt = models.IntegerField(default=0)
ghichu = models.TextField(default='')
def __str__(self):
return str(self.id)
views.py
enter code here
from django.shortcuts import render, redirect
from inputdata.models import GiaoVien
def show(request):
queryset = GiaoVien.objects.all()
context= {'clientes': queryset}
return render(request, "Main/showdata.html", context)
showdata.html
{% extends 'base.html' %}
{% block title %}Show Giao Vien{% endblock %}
{% block content %}
<table>
<thead>
{% for field in clientes %}
<th>{{ field.label }}</th>
{% endfor %}
</thead>
<tbody>
<tr>
{% for field in clientes %}
<td>{{ field.value|default_if_none:'' }}</td>
{% endfor %}
</tr>
</tbody>
</table>
{% endblock content %}