Repository: django-cms/django-cms

Issue:
TypeError: get_query_set() takes exactly 2 arguments (1 given)
As reported on the mailing list, there seems to be a Django 1.4 incompatibility in our admin changelist:

```
Environment:


Request Method: GET
Request URL: http://127.0.0.1:8000/admin/cms/page/

Django Version: 1.4 pre-alpha
Python Version: 2.6.6
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.admin',
 'django.contrib.admindocs',
 'cms',
 'mptt',
 'menus',
 'south',
 'appmedia',
 'cms.plugins.text',
 'cms.plugins.picture',
 'cms.plugins.link',
 'cms.plugins.file',
 'cms.plugins.snippet',
 'cms.plugins.googlemap',
 'sekizai']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'cms.middleware.page.CurrentPageMiddleware',
 'cms.middleware.user.CurrentUserMiddleware',
 'cms.middleware.toolbar.ToolbarMiddleware')


Traceback:
File "C:\Python26\lib\site-packages\django\core\handlers\base.py" in get_response
  111.                         response = callback(request, *callback_args, **callback_kwargs)
File "C:\Python26\lib\site-packages\django\contrib\admin\options.py" in wrapper
  323.                 return self.admin_site.admin_view(view)(*args, **kwargs)
File "C:\Python26\lib\site-packages\django\utils\decorators.py" in _wrapped_view
  91.                     response = view_func(request, *args, **kwargs)
File "C:\Python26\lib\site-packages\django\views\decorators\cache.py" in _wrapped_view_func
  88.         response = view_func(request, *args, **kwargs)
File "C:\Python26\lib\site-packages\django\contrib\admin\sites.py" in inner
  196.             return view(request, *args, **kwargs)
File "C:\Python26\lib\site-packages\django_cms-2.2b1-py2.6.egg\cms\admin\pageadmin.py" in changelist_view
  644.                     self.date_hierarchy, self.search_fields, self.list_select_related, self.list_per_page, self.list_editable, self)
File "C:\Python26\lib\site-packages\django_cms-2.2b1-py2.6.egg\cms\admin\change_list.py" in __init__
  27.         super(CMSChangeList, self).__init__(request, *args, **kwargs)
File "C:\Python26\lib\site-packages\django\contrib\admin\views\main.py" in __init__
  81.         self.query_set = self.get_query_set(request)
File "C:\Python26\lib\site-packages\django_cms-2.2b1-py2.6.egg\cms\admin\change_list.py" in get_query_set
  43.         qs = super(CMSChangeList, self).get_query_set().drafts()

Exception Type: TypeError at /admin/cms/page/
Exception Value: get_query_set() takes exactly 2 arguments (1 given)
```



Discussion:
Is it the ChangeList get_query_set() that's falling over on, or an underlying manager? If its the former, I _think_ it's [16144](https://code.djangoproject.com/changeset/16144) that'd be the culprit (forcing get_query_set() to accept `request`)

good work @kezabelle

https://github.com/divio/django-cms/blob/develop/cms/admin/change_list.py#L43 doesn't propagate the request


Resolving patch:
diff --git a/cms/admin/change_list.py b/cms/admin/change_list.py
--- a/cms/admin/change_list.py
+++ b/cms/admin/change_list.py
@@ -24,9 +24,9 @@ class CMSChangeList(ChangeList):
     real_queryset = False
     
     def __init__(self, request, *args, **kwargs):
-        super(CMSChangeList, self).__init__(request, *args, **kwargs)
         from cms.utils.plugins import current_site
         self._current_site = current_site(request)
+        super(CMSChangeList, self).__init__(request, *args, **kwargs)
         try:
             self.query_set = self.get_query_set(request)
         except:
@@ -40,7 +40,7 @@ def __init__(self, request, *args, **kwargs):
     def get_query_set(self, request=None):
         if COPY_VAR in self.params:
             del self.params[COPY_VAR]
-        qs = super(CMSChangeList, self).get_query_set().drafts()
+        qs = super(CMSChangeList, self).get_query_set(request).drafts()
         if request:
             site = self._current_site
             permissions = Page.permissions.get_change_id_list(request.user, site)
diff --git a/cms/admin/pageadmin.py b/cms/admin/pageadmin.py
--- a/cms/admin/pageadmin.py
+++ b/cms/admin/pageadmin.py
@@ -168,7 +168,7 @@ class Media:
                 'css/jquery.dialog.css',
             )]
         }
-        js = ['%sjs/jquery.min.js' % settings.ADMIN_MEDIA_PREFIX] + [cms_static_url(path) for path in [
+        js = ['%sjs/jquery.min.js' % settings.STATIC_URL] + [cms_static_url(path) for path in [
                 'js/plugins/admincompat.js',
                 'js/libs/jquery.query.js',
                 'js/libs/jquery.ui.core.js',
@@ -518,7 +518,7 @@ def change_view(self, request, object_id, extra_context=None):
                 'page': obj,
                 'CMS_PERMISSION': settings.CMS_PERMISSION,
                 'CMS_MODERATOR': settings.CMS_MODERATOR,
-                'ADMIN_MEDIA_URL': settings.ADMIN_MEDIA_PREFIX,
+                'ADMIN_MEDIA_URL': settings.STATIC_URL,
                 'has_change_permissions_permission': obj.has_change_permissions_permission(request),
                 'has_moderate_permission': obj.has_moderate_permission(request),
                 'moderation_level': moderation_level,
diff --git a/cms/middleware/multilingual.py b/cms/middleware/multilingual.py
--- a/cms/middleware/multilingual.py
+++ b/cms/middleware/multilingual.py
@@ -38,7 +38,7 @@ def patch_response(content, pages_root, language):
     # If the regex matches, the extracted path we want is stored in the fourth group (\4).
     quoted_root = urllib.quote(pages_root)
     ignore_paths = ['%s%s/' % (quoted_root, l[0]) for l in settings.CMS_LANGUAGES]
-    ignore_paths += [settings.MEDIA_URL, settings.ADMIN_MEDIA_PREFIX]
+    ignore_paths += [settings.MEDIA_URL, settings.STATIC_URL]
     if getattr(settings,'STATIC_URL', False):
         ignore_paths += [settings.STATIC_URL]
         
@@ -53,7 +53,7 @@ def patch_response(content, pages_root, language):
     # For understanding this regex, please read the documentation for HREF_URL_FIX_RE above.
     
     ignore_paths = ['%s%s/' % (pages_root, l[0]) for l in settings.CMS_LANGUAGES]
-    ignore_paths += [settings.MEDIA_URL, settings.ADMIN_MEDIA_PREFIX]
+    ignore_paths += [settings.MEDIA_URL, settings.STATIC_URL]
     if getattr(settings,'STATIC_URL', False):
         ignore_paths += [settings.STATIC_URL]
     FORM_URL_FIX_RE = re.compile(ur'<form([^>]+)action=("|\')(?=%s)(?!(%s))(%s(.*?))("|\')(.*?)>' % (
@@ -110,7 +110,7 @@ def process_response(self, request, response):
         #       testing this and throwing an exception otherwise, would probably be a good idea
         
         if not path.startswith(settings.MEDIA_URL) and \
-                not path.startswith(settings.ADMIN_MEDIA_PREFIX) and \
+                not path.startswith(settings.STATIC_URL) and \
                 not (getattr(settings,'STATIC_URL', False) and path.startswith(settings.STATIC_URL)) and \
                 response.status_code == 200 and \
                 response._headers['content-type'][1].split(';')[0] == "text/html":
@@ -131,7 +131,7 @@ def process_response(self, request, response):
             if not has_lang_prefix(location) and location.startswith("/") and \
                     not location.startswith(settings.MEDIA_URL) and \
                     not (getattr(settings,'STATIC_URL', False) and location.startswith(settings.STATIC_URL)) and \
-                    not location.startswith(settings.ADMIN_MEDIA_PREFIX):
+                    not location.startswith(settings.STATIC_URL):
                 response['Location'] = "/%s%s" % (language, location)
         response.set_cookie("django_language", language)
         return response


Test patch: