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

django-nested-admin 4.1.1 with attribute `classes = ['collapse']` is undraggable

Open a8568730 opened this issue 8 months ago • 5 comments

Installed:

  • django==5.1.8
  • django-nested-admin==4.1.1

We found that after we upgrade django-nested-admin from 4.0.2 to 4.1.1, the inlines became undraggable.

Desired behavior

When my cursor hold the handler icon to drag, The target inline shows draggable:

The first inline should be draggable

Actual behavior

My cursor was holding the handler icon to drag, but this inline didn't become draggable:

The first inline actually is draggable

a8568730 avatar May 27 '25 07:05 a8568730

We found that the classes = ['collapse'] cause this problem.

This is our simplified code:

import nested_admin
from hello_dict.models import Category, CategoryRelation


class WordInline(
    nested_admin.SortableHiddenMixin,
    nested_admin.NestedTabularInline,
):
    model = CategoryRelation
    fk_name = 'Category'
    classes = ['collapse'] # <-- this attribute
    sortable_field_name = 'position'


class CategoryAdmin(nested_admin.NestedModelAdmin):
    list_display = ('id',)
    inlines = [WordInline]

When we remove the attribute classes = ['collapse'] , the inlines become draggable and sortable.

a8568730 avatar May 28 '25 10:05 a8568730

I think this is fixed in the 4.1.2 release. Could you confirm?

fdintino avatar Aug 08 '25 15:08 fdintino

Thanks for letting me know about the 4.1.2 release. I'll find some time before September to help confirm if the bug has been fixed.

a8568730 avatar Aug 11 '25 09:08 a8568730

After I update the version of nested-django-admin to 4.1.2, if the NestedTabularInline contains classes = ['collapse'], it is still undraggable.

models.py

from django.db import models

class HeadWord(models.Model):
    word = models.CharField(max_length=25)

class Pronunciation(models.Model):
    headword = models.ForeignKey("HeadWord", on_delete=models.CASCADE)
    pronunce = models.CharField(max_length=50)
    order = models.PositiveIntegerField(help_text="the order of priority")

    class Meta:
        ordering = ['order', ]

admin.py

from django.contrib import admin
import nested_admin

from test_app.models import HeadWord, Pronunciation

class PronunciationInline(nested_admin.NestedTabularInline):
    model = Pronunciation
    fields = ('pronunce', 'order', )
    sortable_field_name = 'order'

    # If I remove the collapse attribute below,
    # the PronunciationInline become draggable in HeadWord chageform.
    classes = ['collapse']

class HeadWordAdmin(nested_admin.NestedModelAdmin):
    list_display = ('id', 'word',)
    inlines = [PronunciationInline, ]

admin.site.register(HeadWord, HeadWordAdmin)

I created a small project for PronunciationInline above to reproduce the undraggable problem: https://github.com/a8568730/testrepo_for_django_nested_admin/

You can checkout the PR #1: Bump django-nested-admin to 4.1.2.

a8568730 avatar Sep 25 '25 07:09 a8568730

I think this is fixed in the 4.1.2 release. Could you confirm?

I installed the 4.1.4 version and the problem persists

maiquelleonel avatar Oct 08 '25 22:10 maiquelleonel