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

Add support for django-unfold #398

Open
twFroggen opened this issue Jul 5, 2024 · 2 comments
Open

Add support for django-unfold #398

twFroggen opened this issue Jul 5, 2024 · 2 comments

Comments

@twFroggen
Copy link

First and foremost, I would like to extend my gratitude for developing such an impressive function.

I am writing to report a compatibility issue I encountered with the django-unfold when integrated with the sortable2 interface. It seems that the styles and action buttons from Sortable2 do not align well with the Unfold design.

image

Could you please consider enhancing the compatibility between these tools in your future updates? Any assistance or guidance in this matter would be greatly appreciated.

Thank you for your attention to this matter. Looking forward to your favorable response.

Best regards,
Froggen

@jrief
Copy link
Owner

jrief commented Jul 5, 2024

Feel free to create a pull request. I currently have no need for django-unfold but I'm open for enhancements to this library.

@Investigamer
Copy link

Investigamer commented Sep 14, 2024

@twFroggen Encountered this same issue, looks like a few people out there have. I managed to solve this issue by extending the SortableAdminMixin class and patching in a modified version of the MovePageActionForm class.

Original MovePageActionForm

class MovePageActionForm(admin.helpers.ActionForm):
    step = IntegerField(
        required=False,
        initial=1,
        widget=widgets.NumberInput(attrs={'id': 'changelist-form-step'}),
        label=False
    )
    page = IntegerField(
        required=False,
        widget=widgets.NumberInput(attrs={'id': 'changelist-form-page'}),
        label=False
    )

MovePageActionForm Patched with Unfold Classes

# from unfold.forms import ActionForm
class UnfoldMovePageActionForm(ActionForm):
    step = IntegerField(
        required=False,
        initial=1,
        # from unfold.widgets import UnfoldAdminIntegerFieldWidget
        widget=UnfoldAdminIntegerFieldWidget(attrs={'id': 'changelist-form-step'}),
        label=False
    )
    page = IntegerField(
        required=False,
        widget=UnfoldAdminIntegerFieldWidget(attrs={'id': 'changelist-form-page'}),
        label=False
    )
    
# Replace action_form in extended class
class UnfoldSortableMixin(SortableAdminMixin):
    action_form = UnfoldMovePageActionForm

# Use it in your model admin
@admin.register(MyModel)
class MyModelAdmin(UnfoldSortableMixin, ModelAdmin):
    # ... stuff here ...

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

No branches or pull requests

3 participants