Django-jet: utils.py -> get_model_queryset() missing 1 required positional argument: 'sortable_by'

Created on 2 Aug 2018  路  8Comments  路  Source: geex-arts/django-jet

This is an incompatible error when you install django-jet==1.0.7 with Django==2.1

Traceback:

Environment:

Request Method: GET
Request URL: http://localhost:8000/admin/xxx/user/1/change/

Django Version: 2.1
Python Version: 3.6.5
Installed Applications:
['jet.dashboard',
'jet',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'storages',
'mobijuce_general',
'mobijuce_util',
'mobijuce',
'mobijuce_admin',
'mobijuce_jwt',
'mobi_apis',
'rest_framework_swagger']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.locale.LocaleMiddleware']

Template error:
In template /home/dang/Projects/python/mjapi/lib/python3.6/site-packages/jet/templates/admin/base.html, error at line 122
__init__() missing 1 required positional argument: 'sortable_by'
112 :
113 : {% block footer %}

{% endblock %}
114 :
115 : {% jet_delete_confirmation_context as delete_confirmation_context %}
116 : {{ delete_confirmation_context }}
117 :
118 : {% jet_change_form_sibling_links_enabled as show_siblings %}
119 : {% if change and show_siblings %}
120 :

121 : {% spaceless %}
122 : {% jet_previous_object as sibling %}
123 :
124 :
125 :
126 : {% if sibling %}
127 : {{ sibling.label }}
128 : {% else %}
129 : ---
130 : {% endif %}
131 :

132 :

Traceback:

File "/home/dang/Projects/python/mjapi/lib/python3.6/site-packages/django/core/handlers/exception.py" in inner

  1. response = get_response(request)

File "/home/dang/Projects/python/mjapi/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response

  1. response = self.process_exception_by_middleware(e, request)

File "/home/dang/Projects/python/mjapi/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response

  1. response = response.render()

File "/home/dang/Projects/python/mjapi/lib/python3.6/site-packages/django/template/response.py" in render

  1. self.content = self.rendered_content

File "/home/dang/Projects/python/mjapi/lib/python3.6/site-packages/django/template/response.py" in rendered_content

  1. content = template.render(context, self._request)

File "/home/dang/Projects/python/mjapi/lib/python3.6/site-packages/django/template/backends/django.py" in render

  1. return self.template.render(context)

File "/home/dang/Projects/python/mjapi/lib/python3.6/site-packages/django/template/base.py" in render

  1. return self._render(context)

File "/home/dang/Projects/python/mjapi/lib/python3.6/site-packages/django/template/base.py" in _render

  1. return self.nodelist.render(context)

File "/home/dang/Projects/python/mjapi/lib/python3.6/site-packages/django/template/base.py" in render

  1. bit = node.render_annotated(context)

File "/home/dang/Projects/python/mjapi/lib/python3.6/site-packages/django/template/base.py" in render_annotated

  1. return self.render(context)

File "/home/dang/Projects/python/mjapi/lib/python3.6/site-packages/django/template/loader_tags.py" in render

  1. return compiled_parent._render(context)

File "/home/dang/Projects/python/mjapi/lib/python3.6/site-packages/django/template/base.py" in _render

  1. return self.nodelist.render(context)

File "/home/dang/Projects/python/mjapi/lib/python3.6/site-packages/django/template/base.py" in render

  1. bit = node.render_annotated(context)

File "/home/dang/Projects/python/mjapi/lib/python3.6/site-packages/django/template/base.py" in render_annotated

  1. return self.render(context)

File "/home/dang/Projects/python/mjapi/lib/python3.6/site-packages/django/template/loader_tags.py" in render

  1. return compiled_parent._render(context)

File "/home/dang/Projects/python/mjapi/lib/python3.6/site-packages/django/template/base.py" in _render

  1. return self.nodelist.render(context)

File "/home/dang/Projects/python/mjapi/lib/python3.6/site-packages/django/template/base.py" in render

  1. bit = node.render_annotated(context)

File "/home/dang/Projects/python/mjapi/lib/python3.6/site-packages/django/template/base.py" in render_annotated

  1. return self.render(context)

File "/home/dang/Projects/python/mjapi/lib/python3.6/site-packages/django/template/loader_tags.py" in render

  1. result = block.nodelist.render(context)

File "/home/dang/Projects/python/mjapi/lib/python3.6/site-packages/django/template/base.py" in render

  1. bit = node.render_annotated(context)

File "/home/dang/Projects/python/mjapi/lib/python3.6/site-packages/django/template/base.py" in render_annotated

  1. return self.render(context)

File "/home/dang/Projects/python/mjapi/lib/python3.6/site-packages/django/template/defaulttags.py" in render

  1. return nodelist.render(context)

File "/home/dang/Projects/python/mjapi/lib/python3.6/site-packages/django/template/base.py" in render

  1. bit = node.render_annotated(context)

File "/home/dang/Projects/python/mjapi/lib/python3.6/site-packages/django/template/base.py" in render_annotated

  1. return self.render(context)

File "/home/dang/Projects/python/mjapi/lib/python3.6/site-packages/django/template/defaulttags.py" in render

  1. return strip_spaces_between_tags(self.nodelist.render(context).strip())

File "/home/dang/Projects/python/mjapi/lib/python3.6/site-packages/django/template/base.py" in render

  1. bit = node.render_annotated(context)

File "/home/dang/Projects/python/mjapi/lib/python3.6/site-packages/django/template/base.py" in render_annotated

  1. return self.render(context)

File "/home/dang/Projects/python/mjapi/lib/python3.6/site-packages/django/template/library.py" in render

  1. output = self.func(resolved_args, *resolved_kwargs)

File "/home/dang/Projects/python/mjapi/lib/python3.6/site-packages/jet/templatetags/jet_tags.py" in jet_previous_object

  1. return jet_sibling_object(context, False)

File "/home/dang/Projects/python/mjapi/lib/python3.6/site-packages/jet/templatetags/jet_tags.py" in jet_sibling_object

  1. queryset = get_model_queryset(admin_site, model, request, preserved_filters=preserved_filters)

File "/home/dang/Projects/python/mjapi/lib/python3.6/site-packages/jet/utils.py" in get_model_queryset

  1. model_admin)

Exception Type: TypeError at /admin/xxx/user/1/change/
Exception Value: __init__() missing 1 required positional argument: 'sortable_by'

Most helpful comment

To fix this error, change jet/utils.py line 220 to 223 like this

cl = ChangeList(request, model, list_display, list_display_links, list_filter, model_admin.date_hierarchy, search_fields, list_select_related, model_admin.list_per_page, model_admin.list_max_show_all, model_admin.list_editable, model_admin, model_admin.sortable_by)

Because from 2.1, Django ChangeList require sortable_by parameter. For more information check https://github.com/django/django/blob/master/django/contrib/admin/views/main.py line 39

All 8 comments

To fix this error, change jet/utils.py line 220 to 223 like this

cl = ChangeList(request, model, list_display, list_display_links, list_filter, model_admin.date_hierarchy, search_fields, list_select_related, model_admin.list_per_page, model_admin.list_max_show_all, model_admin.list_editable, model_admin, model_admin.sortable_by)

Because from 2.1, Django ChangeList require sortable_by parameter. For more information check https://github.com/django/django/blob/master/django/contrib/admin/views/main.py line 39

Please apply better fix in #345

@socrec How can I override jet/utils.py file to add what you say, I must change?

Thank you.

image
@alfredrumss
I'm not sure if this is a recommended method or best practice, since I'm new to django (my background is PHP), but this is what I did while we have to wait for geex-arts to update the bug fix.
Basically, jet is just an app like every other apps that we create, so, I simply just copy it to the the same level with other apps like in the image above. And it just works. Until further updates, I'll just remove or rename that folder just to be sure. And it will load the default jet in lib.
But I recommend you to follow the fix in #345

How is this still broken?

@RoninDusette it was fixed and merged into dev, they just haven't released a new version yet.
Kindly check #345 for more information :)

When this fix omg... I changed model_admin.sortable_by on line 223 still same bug . ffs

@logicappsource the fix at #345 has been merged to geex-arts:dev, you can try to pull from that instead.
Or if you don't want to use dev because of stability concern, you can try this

image
@alfredrumss
I'm not sure if this is a recommended method or best practice, since I'm new to django (my background is PHP), but this is what I did while we have to wait for geex-arts to update the bug fix.
Basically, jet is just an app like every other apps that we create, so, I simply just copy it to the the same level with other apps like in the image above. And it just works. Until further updates, I'll just remove or rename that folder just to be sure. And it will load the default jet in lib.
But I recommend you to follow the fix in #345

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pwndr00t picture pwndr00t  路  4Comments

RamizSami picture RamizSami  路  4Comments

leogout picture leogout  路  8Comments

erayerdin picture erayerdin  路  5Comments

uroybd picture uroybd  路  5Comments