i have python django project where i am using to display all the books and rendering a single book when clicking on each book so django will automatically generate the book details.
so while rendering i want to make the price_upgrade boolean field read only if the user doesn't have a group called author
so my codes like this
class BookAdmin(admin.ModelAdmin):
    list_per_page = 10
    list_display_links = ['name']
    readonly_fields = ('id', 'name', 'city', 'price_upgrade')
    ...
    ...
    ...
def has_change_permission(self, request, obj=None):
        if request.user.groups.all().filter(Group ='author').exists():
            print('author group is there')
        else:
            print('author group is not there')
        #print('request', request.user.groups.all(), type(request.user.groups.all()))
        return True
how can i add the price_upgrade field to readonly_fields if current user doesn't have the group of author else we should remove the price_upgrade field from readonly_fields because he is part of author group so he can edit it
Version python 2.7 django 1.8
Any help appreciated
 
     
    