Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
socrec opened this issue Aug 2, 2018 · 8 comments

Comments

@socrec
Copy link

socrec commented Aug 2, 2018

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 : <a{% if sibling.url %} href="{{ sibling.url }}"{% endif %} class="changeform-navigation-button segmented-button left{% if not sibling %} disabled{% endif %}" title="{{ sibling.label }}">
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
34. response = get_response(request)

File "/home/dang/Projects/python/mjapi/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
156. 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
154. response = response.render()

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

File "/home/dang/Projects/python/mjapi/lib/python3.6/site-packages/django/template/response.py" in rendered_content
83. content = template.render(context, self._request)

File "/home/dang/Projects/python/mjapi/lib/python3.6/site-packages/django/template/backends/django.py" in render
61. return self.template.render(context)

File "/home/dang/Projects/python/mjapi/lib/python3.6/site-packages/django/template/base.py" in render
171. return self._render(context)

File "/home/dang/Projects/python/mjapi/lib/python3.6/site-packages/django/template/base.py" in _render
163. return self.nodelist.render(context)

File "/home/dang/Projects/python/mjapi/lib/python3.6/site-packages/django/template/base.py" in render
937. bit = node.render_annotated(context)

File "/home/dang/Projects/python/mjapi/lib/python3.6/site-packages/django/template/base.py" in render_annotated
904. return self.render(context)

File "/home/dang/Projects/python/mjapi/lib/python3.6/site-packages/django/template/loader_tags.py" in render
150. return compiled_parent._render(context)

File "/home/dang/Projects/python/mjapi/lib/python3.6/site-packages/django/template/base.py" in _render
163. return self.nodelist.render(context)

File "/home/dang/Projects/python/mjapi/lib/python3.6/site-packages/django/template/base.py" in render
937. bit = node.render_annotated(context)

File "/home/dang/Projects/python/mjapi/lib/python3.6/site-packages/django/template/base.py" in render_annotated
904. return self.render(context)

File "/home/dang/Projects/python/mjapi/lib/python3.6/site-packages/django/template/loader_tags.py" in render
150. return compiled_parent._render(context)

File "/home/dang/Projects/python/mjapi/lib/python3.6/site-packages/django/template/base.py" in _render
163. return self.nodelist.render(context)

File "/home/dang/Projects/python/mjapi/lib/python3.6/site-packages/django/template/base.py" in render
937. bit = node.render_annotated(context)

File "/home/dang/Projects/python/mjapi/lib/python3.6/site-packages/django/template/base.py" in render_annotated
904. return self.render(context)

File "/home/dang/Projects/python/mjapi/lib/python3.6/site-packages/django/template/loader_tags.py" in render
62. result = block.nodelist.render(context)

File "/home/dang/Projects/python/mjapi/lib/python3.6/site-packages/django/template/base.py" in render
937. bit = node.render_annotated(context)

File "/home/dang/Projects/python/mjapi/lib/python3.6/site-packages/django/template/base.py" in render_annotated
904. return self.render(context)

File "/home/dang/Projects/python/mjapi/lib/python3.6/site-packages/django/template/defaulttags.py" in render
309. return nodelist.render(context)

File "/home/dang/Projects/python/mjapi/lib/python3.6/site-packages/django/template/base.py" in render
937. bit = node.render_annotated(context)

File "/home/dang/Projects/python/mjapi/lib/python3.6/site-packages/django/template/base.py" in render_annotated
904. return self.render(context)

File "/home/dang/Projects/python/mjapi/lib/python3.6/site-packages/django/template/defaulttags.py" in render
398. 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
937. bit = node.render_annotated(context)

File "/home/dang/Projects/python/mjapi/lib/python3.6/site-packages/django/template/base.py" in render_annotated
904. return self.render(context)

File "/home/dang/Projects/python/mjapi/lib/python3.6/site-packages/django/template/library.py" in render
192. 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
204. 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
168. 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
223. model_admin)

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

@socrec
Copy link
Author

socrec commented Aug 2, 2018

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

socrec added a commit to socrec/django-jet that referenced this issue Aug 2, 2018
For more information check this issue: geex-arts#342
@socrec
Copy link
Author

socrec commented Aug 12, 2018

Please apply better fix in #345

@socrec socrec closed this as completed Aug 12, 2018
@alfredrumss
Copy link

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

Thank you.

@socrec
Copy link
Author

socrec commented Aug 16, 2018

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

igiguitar added a commit to pluribus-one/gdpr-registry-app that referenced this issue Aug 20, 2018
@RoninDusette
Copy link

How is this still broken?

@socrec
Copy link
Author

socrec commented Dec 7, 2018

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

@logicappsource
Copy link

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

@socrec
Copy link
Author

socrec commented Jan 5, 2019

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants