django-nested-inline icon indicating copy to clipboard operation
django-nested-inline copied to clipboard

Fix dependency on jquery for django 2.2+

Open leibowitz opened this issue 4 years ago • 4 comments
trafficstars

https://docs.djangoproject.com/en/3.2/releases/2.2/#merging-of-form-media-assets

jquery.init.js is already defined as a dependency on NestedInline, but not on NestedModelAdmin, causing errors:

Uncaught TypeError: Cannot read property 'fn' of undefined

https://github.com/s-block/django-nested-inline/blob/master/nested_inline/static/admin/js/inlines-nested.js#L18

Fix https://github.com/s-block/django-nested-inline/issues/106

leibowitz avatar Jun 03 '21 13:06 leibowitz

Bumping because this issue is showing up in our error logs at work

daniel-brenot avatar Oct 24 '21 22:10 daniel-brenot

Agreed, would be nice to include it in the next release

Thorbenl avatar Jan 11 '22 16:01 Thorbenl

How does this affect old versions of Django?

OskarPersson avatar Jan 11 '22 18:01 OskarPersson

@leibowitz I just tested this out in Django 1.8 and it results in another error that does not occur on master. Could you add something like this to this PR?

@@ -49,10 +49,15 @@ class NestedModelAdmin(InlineInstancesMixin, admin.ModelAdmin):
         css = {
             "all": ('admin/css/forms-nested.css',)
         }
-        js = (
-            'admin/js/jquery.init.js',
-            'admin/js/inlines-nested%s.js' % ('' if settings.DEBUG else '.min'),
-        )
+        if VERSION[:2] >= (2, 2):
+            js = (
+                'admin/js/jquery.init.js',
+                'admin/js/inlines-nested%s.js' % ('' if settings.DEBUG else '.min'),
+            )
+        else:
+            js = (
+                'admin/js/inlines-nested%s.js' % ('' if settings.DEBUG else '.min'),
+            )
 
     def save_formset(self, request, form, formset, change):
         """

OskarPersson avatar Feb 22 '23 19:02 OskarPersson