On Tuesday, 11 August 2015 06:24:32 UTC+1, Mike Dewhirst wrote:
 

> There is a get_read_only() method in the admin.ModelAdmin class. It 
> normally returns self.readonly_fields but you can give it a callable. 
>
>
> https://docs.djangoproject.com/en/1.8/ref/contrib/admin/#django.contrib.admin.ModelAdmin.get_readonly_fields
>  
>
> As well as defining any readonly fields (for everyone) you want 
> something like ... 
>
> def ro_fields(self, request, obj=None): 
>      if obj is None or request.user.is_superuser: 
>          return self.readonly_fields 
>      else: 
>          return self.model._meta.get_all_field_names() 
>
> ... then get_readonly_fields = ro_fields should make it happen like your 
> pseudocode. 
>
> Mike 
>

Why do you define a separate method, then alias to get_readonly_fields? Why 
not override the method directly?
--
Daniel. 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/b43856c6-4e6f-435a-bee2-886110d2aa1a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to