我正在使用django-pagination包在 tweepy 中对用户推文进行分页。遵循所有必要的说明后,分页似乎不起作用。我想我错过了一些东西。不知道要使用哪个变量来替换“object_list”。我怎样才能让它分页?
错误:
TemplateSyntaxError at /test/
Caught VariableDoesNotExist while rendering: Failed lookup for key [object_list] in u'<tweepy.cursor.ItemIterator object at 0x0437DC10>'
Request Method: GET
Request URL: http://127.0.0.1:8000/test/
Django Version: 1.3.1
Exception Type: TemplateSyntaxError
Exception Value:
Caught VariableDoesNotExist while rendering: Failed lookup for key [object_list] in u'<tweepy.cursor.ItemIterator object at 0x0437DC10>'
Exception Location: C:\Python27\lib\site-packages\django\template\base.py in _resolve_lookup, line 692
Python Executable: C:\Python27\python.exe
Python Version: 2.7.2
模板:
{% extends "base.html" %}
{% load pagination_tags %}
{% block content %}
{% autopaginate treats.object_list 10 %}
{% for treat in treats %}
<center> <p> {{ treat.author.screen_name}} </p>
<p> {{ treat.text|safe }} {{ treat.url }} </p>
<p> {{ treat.created_at }} Via: {{treat.source}} </p> </center>
{% empty %}
<p> Sorry, No Update Could Be Loaded At This Time. </p>
{% endfor %}
{% paginate %}
{% endblock %}
意见:
def testdat(request):
if request.method=="GET":
treats=Cursor(api.list_timeline, owner=request.user, slug="").items(20)
for treat in treats:
treat.__getstate__()
top=Twet(text= treat.text, author_screen_name= treat.author.screen_name, created_at= treat.created_at, source= treat.source)
top.save()
treats=Cursor(api.list_timeline, owner=request.user, slug='').items(20)
return render_to_response('dashy.html',{'treats': treats},context_instance=Requ