我正在为我的网站使用带有 twitter 风格的 django-endless-pagination,它在开发中工作得非常好,但是当我转向生产时,它甚至没有显示条目。我正在使用 webfaction,下面是我已采取的操作列表。
1) PYTHONPATH=$HOME/webapps/csiop/lib/python2.7 easy_install-2.7 --install-dir=$HOME/webapps/csiop/lib/python2.7 --script-dir=$HOME/webapps/csiop/ bin django-endless-pagination 2) python manage.py syncdb 3) 在 settings.py 和下面的 settings.py 中添加 never_pagination
PAGINATION_SETTINGS = {
'PAGE_RANGE_DISPLAYED': 10,
'MARGIN_PAGES_DISPLAYED': 2,
}
4)我的views.py更改为如下所示
def homepage(request):
item_list = items.objects.filter(show_on_website=True)
template = 'homepage.html'
page_template = 'home_page_index.html'
if request.is_ajax():
template = page_template
return render_to_response(template,
{'page_template': page_template,
'item_list': item_list},
context_instance=RequestContext(request))
5)我的模板如下所示。
Homepage.html:-
<h2>Entries:</h2>
{% include page_template %}
{% block js %}
{{ block.super }}
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="{{ STATIC_URL }}endless_pagination/js/endless-pagination.js"></script>
<script>$.endlessPaginate();</script>
{% endblock %}
home_page_index.html:-
{% load endless %}
{% lazy_paginate entries %}
{% for entry in entries %}
{# your code to show the entry #}
{% endfor %}
{% show_more " " %}
上面的代码在我的开发中工作得很好,但在生产中却不行。有人可以帮助我缺少什么吗?
编辑: - 如果我在我的开发环境中将调试模式设置为 False,我会收到以下错误。我也在网站上使用 django-seo,它似乎在抱怨,但我不确定这个错误到底是什么。
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/wsgiref/handlers.py", line 85, in run
self.result = application(self.environ, self.start_response)
File "/Users/django1.5/django1.5_ve/lib/python2.7/site- packages/django/core/handlers/wsgi.py", line 255, in __call__
response = self.get_response(request)
File "/Users/django1.5/django1.5_ve/lib/python2.7/site-packages/django/core/handlers/base.py", line 178, in get_response
response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
File "/Users/django1.5/django1.5_ve/lib/python2.7/site-packages/django/core/handlers/base.py", line 224, in handle_uncaught_exception
return callback(request, **param_dict)
File "/Users/django1.5/django1.5_ve/lib/python2.7/site-packages/django/utils/decorators.py", line 91, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "/Users/django1.5/django1.5_ve/lib/python2.7/site-packages/django/views/defaults.py", line 41, in server_error
return http.HttpResponseServerError(template.render(Context({})))
File "/Users/django1.5/django1.5_ve/lib/python2.7/site-packages/django/template/base.py", line 140, in render
return self._render(context)
File "/Users/django1.5/django1.5_ve/lib/python2.7/site-packages/django/template/base.py", line 134, in _render
return self.nodelist.render(context)
File "/Users/django1.5/django1.5_ve/lib/python2.7/site-packages/django/template/base.py", line 830, in render
bit = self.render_node(node, context)
File "/Users/django1.5/django1.5_ve/lib/python2.7/site-packages/django/template/base.py", line 844, in render_node
return node.render(context)
File "/Users/django1.5/django1.5_ve/lib/python2.7/site-packages/django/template/loader_tags.py", line 124, in render
return compiled_parent._render(context)
File "/Users/django1.5/django1.5_ve/lib/python2.7/site-packages/django/template/base.py", line 134, in _render
return self.nodelist.render(context)
File "/Users/django1.5/django1.5_ve/lib/python2.7/site-packages/django/template/base.py", line 830, in render
bit = self.render_node(node, context)
File "/Users/django1.5/django1.5_ve/lib/python2.7/site-packages/django/template/base.py", line 844, in render_node
return node.render(context)
File "/Users/django1.5/django1.5_ve/lib/python2.7/site-packages/rollyourown/seo/templatetags/seo.py", line 25, in render
raise template.TemplateSyntaxError(msg)
TemplateSyntaxError: {% get_metadata %} needs some path information.
Please use RequestContext with the django.core.context_processors.request context processor.
Or provide a path or object explicitly, eg {% get_metadata for path %} or {% get_metadata for object %}
[09/Apr/2013 18:22:49] "GET / HTTP/1.1" 500 59
谢谢