django-admin-sortable2 icon indicating copy to clipboard operation
django-admin-sortable2 copied to clipboard

Unhandled Promise Rejection

Open shacker opened this issue 2 years ago • 5 comments

admin-sortable2 2.0.4 in my project works fine on localhost. But deployed to a server, the second I touch a drag handle, the console shows this error:

CleanShot 2022-05-24 at 22 58 55@2x

And ordering changes are not saved. Whatever t is, it's undefined! I've confirmed that /static/adminsortable2/js/adminsortable2.min.js is definitely loading, with a 200.

Is this a bug, or could I have misconfigured something?

shacker avatar May 25 '22 06:05 shacker

No one else is encountering this? Any theories?

shacker avatar May 27 '22 06:05 shacker

@shacker This appears to be an issue with the minified version (adminsortable2.min.js) the un-minified version works as expected.

As a temp work around add below code to your admin class that inherits SortableAdminMixin which will remove min from the file path name which is applied when DEBUG = False as per SortableAdminBase - adminsortable2/admin.py line 66.

    @property
    def media(self):
        css = {"all": ["adminsortable2/css/sortable.css"]}
        js = ["adminsortable2/js/adminsortable2.js"]
        return super().media + widgets.Media(css=css, js=js)

Eccleshall avatar Jun 06 '22 17:06 Eccleshall

@Eccleshall thanks for looking at this problem. What do you think, shall I refer to the unminimized version only?

jrief avatar Jun 07 '22 13:06 jrief

@Eccleshall @jrief Thanks for the confirmation! I can live with the workaround until the next release. Cheers!

shacker avatar Jun 08 '22 05:06 shacker

Simply copying the unminified version over the minified also works fine and doesn't need code changes. When a release with a fix is available manage.py collectstatic will switch back to the minified version (assuming the next version contains a fix, thought 2.0.5 would do, but seems not).

christianwgd avatar Jun 22 '22 16:06 christianwgd

Minimizing the JS file has been built into the deployment script. I hope this will fix it.

jrief avatar Aug 11 '22 21:08 jrief

Sorry to say, updated to 2.1.2, but this issue still appears. After copying the unminified version to the minified the error is gone. Before that i deleted the browser cache, reinstalled the library, "force updated" the site and so on.

christianwgd avatar Aug 17 '22 18:08 christianwgd

Fixed in version 2.1.3 by using terser instead of uglify.

jrief avatar Aug 30 '22 20:08 jrief