Re: Admin site pages + display or hiding instance owner field
I think it should be pretty easy to do.
The get_form() method on ModelAdmin returns the form, and it knows
about the current request. So you could modify that to remove the
field after the form is generated.
class MyModelAdmin(admin.ModelAdmin):
def get_form(self, request, obj=None, **kwargs):
form = super(MyModelAdmin,self).get_form(request, obj,
**kwargs)
if request.uesr.is_super_user:
del form.fields['whatever']
return form
admin.site.register(MyModel, MyModelAdmin)
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home