bugfix: ModelTableOptions() should call TableOptions.__init__
authoradammck <adam.mckaig@gmail.com>
Fri, 16 Apr 2010 03:36:15 +0000 (23:36 -0400)
committerMichael Elsdoerfer <michael@elsdoerfer.com>
Wed, 21 Apr 2010 07:15:55 +0000 (09:15 +0200)
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
tests/test_models.py

index 4a24ad502ec464a834a4aa999c271311502efd98..e1085a6e1a451c12d3e38e84767f86987f38667a 100644 (file)
@@ -9,7 +9,7 @@ __all__ = ('ModelTable',)
 \r
 class ModelTableOptions(TableOptions):\r
     def __init__(self, options=None):\r
-        super(ModelTableOptions, self).__init__()\r
+        super(ModelTableOptions, self).__init__(options)\r
         self.model = getattr(options, 'model', None)\r
         self.columns = getattr(options, 'columns', None)\r
         self.exclude = getattr(options, 'exclude', None)\r
index 47485a0c30a9e7b8746e31c3cc8cd753fbaccf2d..1c53b587480d9ff431b5e72b13161e50a1cd7642 100644 (file)
@@ -212,6 +212,9 @@ def test_default_sort():
             model = Country\r
             order_by = '-name'\r
 \r
+    # the order_by option is provided by TableOptions\r
+    assert_equal('-name', SortedCountryTable()._meta.order_by)\r
+\r
     # the default order can be inherited from the table\r
     assert_equal(('-name',), SortedCountryTable().order_by)\r
     assert_equal(4, SortedCountryTable().rows[0]['id'])\r