Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 41f8171

Browse files
adammckmiracle2k
authored andcommitted
bugfix: ModelTableOptions() should call TableOptions.__init__
any options specified in the Meta of a ModelTable were not being passed along to the constructor of TableOptions. this wasn't noticed before, but now that order_by is an option of TableBase, it became obvious.
1 parent a3028b7 commit 41f8171

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

django_tables/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
class ModelTableOptions(TableOptions):
1111
def __init__(self, options=None):
12-
super(ModelTableOptions, self).__init__()
12+
super(ModelTableOptions, self).__init__(options)
1313
self.model = getattr(options, 'model', None)
1414
self.columns = getattr(options, 'columns', None)
1515
self.exclude = getattr(options, 'exclude', None)

tests/test_models.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,9 @@ class Meta:
212212
model = Country
213213
order_by = '-name'
214214

215+
# the order_by option is provided by TableOptions
216+
assert_equal('-name', SortedCountryTable()._meta.order_by)
217+
215218
# the default order can be inherited from the table
216219
assert_equal(('-name',), SortedCountryTable().order_by)
217220
assert_equal(4, SortedCountryTable().rows[0]['id'])

0 commit comments

Comments
 (0)