From: adammck Date: Fri, 16 Apr 2010 03:36:15 +0000 (-0400) Subject: bugfix: ModelTableOptions() should call TableOptions.__init__ X-Git-Tag: 0.2~11 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=41f8171e10f311284d5408ba1faac03695bb7509;p=django-tables2.git 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. --- diff --git a/django_tables/models.py b/django_tables/models.py index 4a24ad5..e1085a6 100644 --- a/django_tables/models.py +++ b/django_tables/models.py @@ -9,7 +9,7 @@ __all__ = ('ModelTable',) class ModelTableOptions(TableOptions): def __init__(self, options=None): - super(ModelTableOptions, self).__init__() + super(ModelTableOptions, self).__init__(options) self.model = getattr(options, 'model', None) self.columns = getattr(options, 'columns', None) self.exclude = getattr(options, 'exclude', None) diff --git a/tests/test_models.py b/tests/test_models.py index 47485a0..1c53b58 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -212,6 +212,9 @@ def test_default_sort(): model = Country order_by = '-name' + # the order_by option is provided by TableOptions + assert_equal('-name', SortedCountryTable()._meta.order_by) + # the default order can be inherited from the table assert_equal(('-name',), SortedCountryTable().order_by) assert_equal(4, SortedCountryTable().rows[0]['id'])