Skip to content

OrderableTabularInline breaks when another inline is present: sortable is not a function #62

@MarvinRucinski

Description

@MarvinRucinski

Hi, thanks for the library.

I found an issue with OrderableTabularInline in Django admin when the parent ModelAdmin has more than one inline.

Actual behavior

On the change form, JavaScript throws:

jQuery.Deferred exception: ... .sortable is not a function

When there are two inlines:

  1. one OrderableTabularInline
  2. one regular TabularInline

If I remove the second inline, drag and drop starts working again.

Expected behavior

OrderableTabularInline should work reliably with multiple inlines on the same admin form, without JavaScript errors.

Likely cause

The package Media currently injects legacy external scripts from CDN:

  1. jQuery 1.11.2
  2. jQuery UI 1.11.2

In modern Django admin, django.jQuery and global jQuery may differ, and sortable can be attached to a different jQuery instance than the one used in inline initialization.

Environment

  1. Django 5.x
  2. django-orderable 6.1.2
  3. Chrome
  4. Admin change form with two inlines (orderable + regular)

Steps to reproduce

  1. Create a parent ModelAdmin with two inlines:
    1. Inline A: OrderableTabularInline with sort_order
    2. Inline B: regular TabularInline
  2. Open parent change form in Django admin
  3. Check console, see error: sortable is not a function
  4. Remove Inline B and reload
  5. Drag and drop works again

Notes

I can help test a patch if needed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions