Repository: django-oscar/django-oscar

Issue:
Support django-tables 1.2
I was trying to see the customers for my e-commerce web site project, and when i click in customers option in customers menu i got this error:
![valueerror at -dashboard-users- - mozilla firefox_141](https://cloud.githubusercontent.com/assets/5034215/17465633/b73b4282-5cc2-11e6-95b6-15e09a70ce9c.png)

Here are the traceback:

``` bash
Environment:


Request Method: GET
Request URL: http://localhost:8000/dashboard/users/

Django Version: 1.9.9
Python Version: 3.5.2
Installed Applications:
['jet.dashboard',
 'jet',
 'axes',
 'cashondelivery',
 'django_extensions',
 'oscarapi',
 'paypal',
 'payu',
 'rest_framework',
 'robots',
 'widget_tweaks',
 'webpack_loader',
 'django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.flatpages',
 'oscar',
 'oscar.apps.analytics',
 'oscar.apps.checkout',
 'oscar.apps.address',
 'oscar.apps.shipping',
 'oscar.apps.catalogue',
 'oscar.apps.catalogue.reviews',
 'oscar.apps.partner',
 'oscar.apps.basket',
 'oscar.apps.payment',
 'oscar.apps.offer',
 'oscar.apps.order',
 'oscar.apps.customer',
 'oscar.apps.promotions',
 'oscar.apps.search',
 'oscar.apps.voucher',
 'oscar.apps.wishlists',
 'oscar.apps.dashboard',
 'oscar.apps.dashboard.reports',
 'oscar.apps.dashboard.users',
 'oscar.apps.dashboard.orders',
 'oscar.apps.dashboard.promotions',
 'oscar.apps.dashboard.catalogue',
 'oscar.apps.dashboard.offers',
 'oscar.apps.dashboard.partners',
 'oscar.apps.dashboard.pages',
 'oscar.apps.dashboard.ranges',
 'oscar.apps.dashboard.reviews',
 'oscar.apps.dashboard.vouchers',
 'oscar.apps.dashboard.communications',
 'oscar.apps.dashboard.shipping',
 'haystack',
 'treebeard',
 'sorl.thumbnail',
 'django_tables2',
 'debug_toolbar']
Installed Middleware:
['debug_toolbar.middleware.DebugToolbarMiddleware',
 'django.middleware.gzip.GZipMiddleware',
 'django.middleware.http.ConditionalGetMiddleware',
 'django.middleware.security.SecurityMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.locale.LocaleMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'oscar.apps.basket.middleware.BasketMiddleware',
 'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware']



Traceback:

File "/home/salahaddin/Proyectos/demo-oscar/lib/python3.5/site-packages/django/core/handlers/base.py" in get_response
  149.                     response = self.process_exception_by_middleware(e, request)

File "/home/salahaddin/Proyectos/demo-oscar/lib/python3.5/site-packages/django/core/handlers/base.py" in get_response
  147.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/home/salahaddin/Proyectos/demo-oscar/lib/python3.5/site-packages/django/contrib/auth/decorators.py" in _wrapped_view
  23.                 return view_func(request, *args, **kwargs)

File "/home/salahaddin/Proyectos/demo-oscar/lib/python3.5/site-packages/django/views/generic/base.py" in view
  68.             return self.dispatch(request, *args, **kwargs)

File "/home/salahaddin/Proyectos/demo-oscar/lib/python3.5/site-packages/oscar/apps/dashboard/users/views.py" in dispatch
  41.         return super(IndexView, self).dispatch(request, *args, **kwargs)

File "/home/salahaddin/Proyectos/demo-oscar/lib/python3.5/site-packages/django/views/generic/base.py" in dispatch
  88.         return handler(request, *args, **kwargs)

File "/home/salahaddin/Proyectos/demo-oscar/lib/python3.5/site-packages/django/views/generic/base.py" in get
  157.         context = self.get_context_data(**kwargs)

File "/home/salahaddin/Proyectos/demo-oscar/lib/python3.5/site-packages/oscar/apps/dashboard/users/views.py" in get_context_data
  103.         context = super(IndexView, self).get_context_data(**kwargs)

File "/home/salahaddin/Proyectos/demo-oscar/lib/python3.5/site-packages/django_tables2/views.py" in get_context_data
  101.         table = self.get_table()

File "/home/salahaddin/Proyectos/demo-oscar/lib/python3.5/site-packages/oscar/apps/dashboard/users/views.py" in get_table
  98.         table = super(IndexView, self).get_table(**kwargs)

File "/home/salahaddin/Proyectos/demo-oscar/lib/python3.5/site-packages/django_tables2/views.py" in get_table
  82.         table = table_class(self.get_table_data(), **kwargs)

File "/home/salahaddin/Proyectos/demo-oscar/lib/python3.5/site-packages/django_tables2/tables.py" in __init__
  348.         self.data = self.TableDataClass(data=data, table=self)

File "/home/salahaddin/Proyectos/demo-oscar/lib/python3.5/site-packages/django_tables2/tables.py" in __init__
  45.             ' list(data) -- {} has neither'.format(type(data).__name__)

Exception Type: ValueError at /dashboard/users/
Exception Value: data must be QuerySet-like (have count() and order_by()) or support list(data) -- NoneType has neither
```

Can anyone help me with this?

I have `django==1.9.9` and `django-oscar==1.2.2` and `django-tables2==1.2.5`.

Thanks!

Seems that problem is with lastest `django-tables2` version. 
Have you guys plans for make `django-oscar` compatible?



Discussion:
django-tables2 1.2 is not supported yet, see setup.py. PR's are welcome

Please, anyone wants help with this?
 When i finish with twoo oscar projects i want help with this.

@SalahAdDin it's better to use django-tables2 version from setup.py until 1.2 support added, as @mvantellingen suggests.

Yes, i do this, so, as i said, when finish this project, i'll work in 1.2 integration.


Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -44,7 +44,7 @@
     # Used for oscar.test.newfactories
     'factory-boy>=2.4.1,<3.0',
     # Used for automatically building larger HTML tables
-    'django-tables2>=1.0.4,<1.1',
+    'django-tables2>=1.2,<1.3',
     # Used for manipulating form field attributes in templates (eg: add
     # a css class)
     'django-widget-tweaks>=1.4.1',
diff --git a/src/oscar/apps/dashboard/catalogue/views.py b/src/oscar/apps/dashboard/catalogue/views.py
--- a/src/oscar/apps/dashboard/catalogue/views.py
+++ b/src/oscar/apps/dashboard/catalogue/views.py
@@ -61,7 +61,7 @@ def filter_products(queryset, user):
     return queryset.filter(stockrecords__partner__users__pk=user.pk).distinct()
 
 
-class ProductListView(SingleTableMixin, generic.TemplateView):
+class ProductListView(SingleTableMixin, generic.ListView):
     """
     Dashboard view of the product list.
     Supports the permission-based dashboard.
@@ -92,7 +92,7 @@ def get_table(self, **kwargs):
         table.caption = self.get_description(self.form)
         return table
 
-    def get_table_pagination(self):
+    def get_table_pagination(self, table):
         return dict(per_page=20)
 
     def filter_queryset(self, queryset):
@@ -518,7 +518,7 @@ def get_queryset(self):
         return self.model.objects.all()
 
 
-class CategoryListView(SingleTableMixin, generic.TemplateView):
+class CategoryListView(SingleTableMixin, generic.ListView):
     template_name = 'dashboard/catalogue/category_list.html'
     table_class = CategoryTable
     context_table_name = 'categories'
diff --git a/src/oscar/apps/dashboard/users/views.py b/src/oscar/apps/dashboard/users/views.py
--- a/src/oscar/apps/dashboard/users/views.py
+++ b/src/oscar/apps/dashboard/users/views.py
@@ -24,7 +24,7 @@
 User = get_user_model()
 
 
-class IndexView(BulkEditMixin, SingleTableMixin, FormMixin, TemplateView):
+class IndexView(BulkEditMixin, SingleTableMixin, FormMixin, ListView):
     template_name = 'dashboard/users/index.html'
     table_pagination = True
     model = User


Test patch: