Thanks for your answer Tim.

def get_form(self, request, obj=None, **kwargs):
form = super(RowModelAdmin, self).get_form(request, obj, **kwargs)
 if not request.user.is_superuser:
* **del form['compilatore']*
 return form

It seems that the object returned by get_form does not behave like a dict().
It does not support .remove or iteration too.

Here is the error I receive:
*'ModelFormMetaclass' object does not support item deletion*
Exception Type: TypeError
Exception Value:
'ModelFormMetaclass' object does not support item deletion
Python Version: 2.6.4


------------
skype: masdero, icq: 473891447, yim: mas_dero, msn: mas_d...@hotmail.com
------------
Mi scriva in italiano; Write me in English; Skribu al mi Esperante!



On Tue, Jan 19, 2010 at 18:31, Tim <timster...@gmail.com> wrote:

> 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)
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>
>
>
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Reply via email to