Schule als Staat Projekt Web, Dokumente, etc.
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

22 行
567B

  1. from django.shortcuts import render
  2. import math
  3. from .models import Entry
  4. # Create your views here.
  5. def index(request):
  6. query = ""
  7. if request.method == 'POST':
  8. query = request.POST['query']
  9. objects = Entry.objects.filter(title__icontains=query)
  10. else:
  11. objects = Entry.objects.all()
  12. rows = group(objects, 3)
  13. return render(request, "datenbank/index.html", {'rows': rows,
  14. 'query': query})
  15. def group(l, n):
  16. return [l[k*n:k*n+n] for k in range(math.ceil(len(l) / n))]