2015-01-09 93 views

回答

2

我實現我需要什麼,在我的內聯類下面的代碼:

def get_formset(self, request, obj=None, **kwargs): 
     if request.user.groups.all().count() > 0: 
      if request.user.groups.all()[0].name == 'User Group Name': 
       kwargs['exclude'] = ['field_to_exclude',] 
     return super(MyInline, self).get_formset(request, obj, **kwargs) 

回答這個問題給我的提示:different fields for add and change pages in admin