Issue
I currently having problem trying to figure out how can i put 3 inline in a single tab on the change view.
I currently have the following admin for one of the view as follow:
class UserAdminCustom(admin.ModelAdmin):
list_display = ('id', 'email', 'status', 'created')
verbose_name = "General"
exclude = ('password', 'last_login', 'is_superuser', 'is_staff', 'groups',
'user_permissions', 'username', 'first_name', 'last_name', 'is_active', 'date_joined', 'modified')
inlines = [
UserKycInline, UserWalletInline, UserBankInline, CardBindingInline, TopUpsInline, TransfersInline, WithdrawalsInline
]
def get_queryset(self, request):
qs = super(UserAdminCustom, self).get_queryset(request)
return qs.filter(is_staff=False)
def get_readonly_fields(self, request, obj=None):
return ('id', 'created', 'modified')
admin.site.register(User, UserAdminCustom)
i currently want TopUpsInline, TransfersInline, WithdrawalsInline
to all be in 1 tab name transactions
. I figure i would use fieldsets but it only work on the user fields and can't be apply to the Inline.
Is there anyway i can show 3 inline in 1 custom tab on change view ?
Solution
I found that django-baton template does support custom form tab and i managed to get 3 inlines in a single tab
https://django-baton.readthedocs.io/en/latest/form_tabs.html
inlines = [
UserKycInline, UserWalletInline, UserBankInline, CardBindingInline, TopUpsInline, TransfersInline, WithdrawalsInline,
]
fieldsets = (
('General', {
'fields': ('id', 'uid', 'phone_number', 'nickname', 'status', 'eth_address', 'evt_address', 'created', 'modified',),
'classes': ('baton-tabs-init', 'baton-tab-group-fs-kyc--inline-userkyc', 'baton-tab-group-fs-wallets--inline-user_wallet', 'baton-tab-group-fs-banks--inline-user_bank', 'baton-tab-group-fs-cards--inline-user_binding', 'baton-tab-group-fs-transactions--inline-user_toptup--inline-transfers--inline-user_transfer--inline-user_withdrawal', ),
}),
('KYC', {
'fields': (),
'classes': ('tab-fs-kyc', ),
}),
('WALLETS', {
'fields': (),
'classes': ('tab-fs-wallets', ),
}),
('BANKS', {
'fields': (),
'classes': ('tab-fs-banks', ),
}),
('CARDS', {
'fields': (),
'classes': ('tab-fs-cards', ),
}),
('Transactions', {
'fields': (),
'classes': ('tab-fs-transactions', ),
}),
)
Answered By - Linh Nguyen
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.