0

I followed the tutorials to install django's pagination settings with python. When I try to declare a paginator object in my views.py I receive an "Identation error" when I try to load the associated template.

I'm able to get pagination working without declaring a paginator in views.py, but I want to customize the page settings.

I imported the pagination directory at the top of my views.py, and I believe I set everything up in my settings.py folder. I know I'm not misstyping the declaration because it's a simple one-liner:

c = RequestContext(request, { "test": testObj, })

p = Paginator (testObj, 100)

return HttpResponse(t.render(c))

What could be causing this error?

Error:

IndentationError at /result/

unexpected indent (views.py, line 90)

Request Method:     GET
Request URL:    http://127.0.0.1:8000/result/xxx
Django Version:     1.5
Exception Type:     IndentationError
Exception Value:    

unexpected indent (views.py, line 90)

Exception Location:     C:\Python27\lib\site-packages\django\utils\importlib.py in import_module, line 35
Python Executable:  C:\Python27\python.exe
Python Version:     2.7.3
Python Path:    

['C:\\Users\\xxx\\Desktop\\xxx',
 'C:\\Python27\\lib\\site-packages\\django_pagination-1.0.7-py2.7.egg',
 'C:\\Windows\\system32\\python27.zip',
 'C:\\Python27\\DLLs',
 'C:\\Python27\\lib',
 'C:\\Python27\\lib\\plat-win',
 'C:\\Python27\\lib\\lib-tk',
 'C:\\Python27',
 'C:\\Python27\\lib\\site-packages']

Server time:    Fri, 22 Mar 2013 14:38:29 -0400
4

1 回答 1

2

我不确定您使用的是什么文本编辑器,但在 gedit 中,您可以将制表符和/或空格显示为箭头,这有助于轻松检测是否存在杂散制表符和/或空格。

于 2013-03-22T18:55:31.817 回答