正常的写法如下所示:
data = models.PrettyNum.objects.filter(id=9).order_by('-id')
用法
###在视图函数中,
def samplerlist(request):
search_dict = {}
search_key = request.GET.get('q', '')
if search_key:
search_dict["key"] = search_key
data = models.xxx.objects.filter(**search_dict).order_by('-id')
page_object = Pagination(request, data, )
context = {
'data': page_object.queryset,
'search_key': search_key,
'page_string': page_object.html()
}
###在 模板页面中
{{ page_string }}
#安装mysqlclient
pip install mysqlclient