from django.shortcuts import render from app01.models import student # Create your views here. def show_one(request): #讀取一筆資料:cname =張三 try: item = student.objects.get(cname='張三') except Exception as e: errormsg = '讀取資料出現錯誤:' + e return render(request,'show_one.html',locals()) def show_all(request): items = student.objects.all().order_by('-id') return render(request,'show_all.html',locals()) def show_all_base(request): items = student.objects.all('cbirthday') return render(request,'show_all_base.html',locals())