From 41f8171e10f311284d5408ba1faac03695bb7509 Mon Sep 17 00:00:00 2001 From: adammck Date: Thu, 15 Apr 2010 23:36:15 -0400 Subject: [PATCH] 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. --- django_tables/models.py | 2 +- tests/test_models.py | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) 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']) -- 2.26.2