获取您的 Django 服务器
template.html
views.py
 
<!DOCTYPE html>
<html>
<body>

<p>The queryset object:</p>

{{ mymembers }}

<p>Loop through the items:</p>

<table border='1'>
  {% for x in mymembers %}
    <tr>
      <td>{{ x }}</td>
    </tr>
  {% endfor %}
</table>

</body>
</html>                  
from django.http import HttpResponse
from django.template import loader
from .models import Member

def testing(request):
  mydata = Member.objects.values_list('firstname')
  template = loader.get_template('template.html')
  context = {
    'mymembers': mydata,
  }
  return HttpResponse(template.render(context, request))
    


# Check out template.html to see how the mymembers object
# was used in the HTML code.                  
127.0.0.1:8000/testing