- def __init__(self, queryset_var=None):
- if queryset_var:
- self.queryset_var = template.Variable(queryset_var)
- else:
- self.queryset_var = None
+ """
+ Emits the required objects to allow for Digg-style pagination.
+
+ First, it looks in the current context for the variable specified. This
+ should be either a QuerySet or a list.
+
+ 1. If it is a QuerySet, this ``AutoPaginateNode`` will emit a
+ ``QuerySetPaginator`` and the current page object into the context names
+ ``paginator`` and ``page_obj``, respectively.
+
+ 2. If it is a list, this ``AutoPaginateNode`` will emit a simple
+ ``Paginator`` and the current page object into the context names
+ ``paginator`` and ``page_obj``, respectively.
+
+ It will then replace the variable specified with only the objects for the
+ current page.
+
+ .. note::
+
+ It is recommended to use *{% paginate %}* after using the autopaginate
+ tag. If you choose not to use *{% paginate %}*, make sure to display the
+ list of availabale pages, or else the application may seem to be buggy.
+ """
+ def __init__(self, queryset_var, paginate_by=DEFAULT_PAGINATION, orphans=DEFAULT_ORPHANS):
+ self.queryset_var = template.Variable(queryset_var)
+ self.paginate_by = paginate_by
+ self.orphans = orphans