Django Paging Linaro-django-pagination

Source: Internet
Author: User

1. Installationlinaro-django-pagination

Settings

Installed_apps = (    # ...    'linaro_django_pagination',) Middleware_classes= (    # ...    'Linaro_django_pagination.middleware.PaginationMiddleware',) Template_context_processors= (#in 1.7 This option is canceled by default, seemingly. How we go about loading in templates and views is an important issue.    'Django.contrib.auth.context_processors.auth',    'Django.core.context_processors.debug',    'django.core.context_processors.i18n',    'Django.core.context_processors.media',    'django.core.context_processors.static',    'Django.core.context_processors.tz',    'django.contrib.messages.context_processors.messages',    'django.core.context_processors.request',)

Views

  @login_required  def   documents (Request): Project  =d_category.objects.all () Doc  =docs.objects.all ()  return  render_to_response ( '  

context_instance=RequestContext(request)比较重要

These processors will be called in RequestContext order and put some predefined variables into the current context. For example, the ' Django.core.context_processors.auth ' function is to pass variables such as user, messages, perms, etc. to the template by default, describing the current logged on user, the current logged on user's message list, and the currently logged on user's permissions. Finally, when you use the Render_to_response method, RequestContext should be passed in as its third parameter. This is the problem I encountered in 1.7, if you do not use, then wait for the error.

Use in templates

{% load pagination_tags%}            {% autopaginate object_list 10%}           {% forMessageinchObject_list%}           <tr> <td><input type="checkbox" class="Choose"Value="{{message.pk}}"></td> &LT;TDclass="Name {% if Message.is_read%}read{% endif%}"> System Message {%ifMessage.is_read%} (read) {% endif%}</td> <tdclass=" Time">{{message.create_time|date:"y-m-d"}}</td> <td><a href="{{Message.get_absolute_url}}" class="btn Btn_blue"> View </a></td> </tr>           {% ENDFOR%}       </table> </form> <divclass="NextPage"> <br> <span>{% paginate%}</span> </div>

Django Paging Linaro-django-pagination

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.