django-nested-inline
django-nested-inline copied to clipboard
Fix dependency on jquery for django 2.2+
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
Bumping because this issue is showing up in our error logs at work
Agreed, would be nice to include it in the next release
How does this affect old versions of Django?
@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):
"""