Closed avelosa closed 2 years ago
In order to reproduce this error, please follow the steps described in https://django-admin-sortable2.readthedocs.io/en/latest/contributing.html#run-the-demo-app
You may clone the repository, add your model changes to the testapp
, and commit it. I then will try to run it in my environment.
I didn't have to change any model or add a new one to reproduce the issue. When running the App I went to the listing page of the 5th book (UnsortedBookAdmin
) in the Test App and I saw the javascript error in the console.
https://user-images.githubusercontent.com/1669158/167904994-80c4d531-c222-439a-b565-5b59aa725519.mov
Thanks for reporting. This issue has been fixed in version 2.0.4
Thank you for fixing this @jrief 🌞
Seeing the same error as described in https://github.com/jazzband/django-admin-sortable/issues/256
python version == 3.9.11 Django version == 4.0.4 adminsortable2 version == 2.0.3
It's a little bit more of a pain for us because we have cypress ui automation tests that fail due to the console error.
FWIW I think there are a couple issues:
the django admin change_list.html template is missing the element with
id="admin_sortable2_config"
. In the JavaScript classSortableBase
the constructor does:this.config=JSON.parse(document.getElementById("admin_sortable2_config")
and thus the error mentioned above.SortableAdminBase
is missing the change_list template override.In the JS the
ActionForm
class assumes an element withid="changelist-form-step"
exists. The following error appears in the browser console:I think this is due to
SortableAdminBase
not havingaction_form = MovePageActionForm
set.Probably not an issue for most Django users: we have admin users who are not superusers and so we restrict access to the admin change list dropdown select element and do not render it. This element matches the query selector
select[name="action"]
inActionForm
. I think it would be helpful if the conditional for creating anew ActionForm
in thewindow.addEventListener
function would check for theselect[name="action"]
element in addition to the#changelist-form
element.... I'll probably open a pull request.