How to edit custom field in django TabularInline

670 Views Asked by At

I have a following inline model under company management. i want to make editable those custom field under company detail page. anyone has a suggestion that how to make editable field 'email', 'name' and 'role'.

I will send it to API while submitting. so it's not concern that how to save it.

Following is my inline model

class CompanyUserInfoTAB(admin.TabularInline):
    model = Userrolemapping
    fields = ['id', 'email', 'name','role']
    extra = 0
    can_delete = False
    verbose_name = 'COMPANY USERs'
    verbose_name_plural = verbose_name

    def email(self, obj):
        return obj.user.email

    def name(self, obj):
        return obj.user.name

    def role(self, obj):
        return UserType.objects.get(usr_type_id=obj.role_id).name

    def company_id(self, obj):
        return obj.company.id

    def get_queryset(self, request):
        qs = super(CompanyUserInfoTAB, self).get_queryset(request)
        return qs.exclude(mod_id="PSS")

Thanks In Advance.

0

There are 0 best solutions below