Skip to content

feat: automatically convert standard model admins for unfold #1331

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

gearheart
Copy link

When model admin is not inherited from unfold's ModelAdmin - then the form looks unstyled. It's easy to avoid with own applications, but makes it a little tedious to install and use third-party apps - because I need to unregister and replace builtin admin classes.
I thought it would be great if third party apps would just work at least for simple cases. So I made this simple slightly magic trick, that does work for me at least on simple cases.

When new "unfold.contrib.convert" is added to INSTALLED_APPS (in the last position) it:
1. Finds all admin classes that are not subclasses of unfold.admin.ModelAdmin
2. Unregisters them
3. Creates new classes that inherit from both the original admin and unfold.admin.ModelAdmin
4. Fixes any inlines by creating new classes that inherit from unfold inline classes
5. Registers the new classes

This is a very basic conversion, but it does reduces a friction of using unfold with third party apps for me.

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

Successfully merging this pull request may close these issues.

1 participant