django-nested-admin 4.1.1 with attribute `classes = ['collapse']` is undraggable
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:
Actual behavior
My cursor was holding the handler icon to drag, but this inline didn't become draggable:
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.
I think this is fixed in the 4.1.2 release. Could you confirm?
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.
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.
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