File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ class RequestConfig(object):
12
12
default ``per_page`` value).
13
13
14
14
"""
15
- def __init__ (self , request , paginate = True ):
15
+ def __init__ (self , request , paginate ):
16
16
self .request = request
17
17
self .paginate = paginate
18
18
Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ class SingleTableMixin(object):
26
26
table_class = None
27
27
table_data = None
28
28
context_table_name = None
29
+ paginate = True
29
30
30
31
def get_table (self ):
31
32
"""
@@ -34,7 +35,8 @@ def get_table(self):
34
35
"""
35
36
table_class = self .get_table_class ()
36
37
table = table_class (self .get_table_data ())
37
- RequestConfig (self .request ).configure (table )
38
+ paginate = self .get_paginate ()
39
+ RequestConfig (self .request , paginate ).configure (table )
38
40
return table
39
41
40
42
def get_table_class (self ):
@@ -64,6 +66,20 @@ def get_table_data(self):
64
66
raise ImproperlyConfigured (u"Table data was not specified. Define "
65
67
u"%(cls)s.table_data"
66
68
% {"cls" : type (self ).__name__ })
69
+
70
+ def get_paginate (self ):
71
+ """
72
+ Returns pagination options: True for default, False for no pagination, and a dictionary for custom pagination.
73
+ """
74
+ if isinstance (self .paginate , int ):
75
+ return bool (self .paginate )
76
+ else :
77
+ try :
78
+ # Duck type for dictionary-like objects
79
+ self .paginate .keys ()
80
+ return self .paginate
81
+ except TypeError :
82
+ print "%(cls)s.paginate must be true, false, or a dictionary." % {"cls" : type (self ).__name__ }
67
83
68
84
def get_context_data (self , ** kwargs ):
69
85
"""
You can’t perform that action at this time.
0 commit comments