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

Fix dependency on jquery for django 2.2+ #127

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

leibowitz
Copy link
Contributor

@leibowitz leibowitz commented Jun 3, 2021

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 #106

@daniel-brenot
Copy link
Collaborator

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

@Thorbenl
Copy link
Contributor

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

@OskarPersson
Copy link
Owner

How does this affect old versions of Django?

@OskarPersson
Copy link
Owner

@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):
         """

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

Successfully merging this pull request may close these issues.

Uncaught TypeError: Cannot read property 'fn' of undefined
4 participants