On Thu, Oct 10, 2013 at 10:04 AM, Roberto López López
<[email protected]>wrote:

> This is, for example, my code overriding get_readonly_fields():
>
>     def get_readonly_fields(self, request, obj=None):
>         readonly = super(NewsAdmin, self).get_readonly_fields(request, obj)
>         if request.user.groups.filter(name__exact='administration') or
> request.user.is_superuser:
>             return readonly
>         else:
>             import itertools
>             return itertools.chain(readonly, ('is_featured',))
>
>
>
I do not understand your logic as it compares to your description of the
problem.

For your described problem:
If the user is_superuser then you shouldn't set read_only at all.

If a user is in a specific set of users then set read_only= ['field1',
'field2',] as appropriate.

It is a pretty simple problem it looks like you are making it far too
complex. ????










>
> On 10/10/2013 02:45 PM, Roberto López López wrote:
> > Hi,
> >
> > In my project I make use of django-admin. I need to have different
> > readonly_fields depending on the user is connected, thus administrators
> > will be able to modify all fields, and other users less fields. Which
> > method do I have to override? I have already tried
> > ModelAdmin.get_readonly_fields() and ModelAdmin.get_form(). But no
> success.
> >
> > Any other suggestions?
> >
> > Thanks!
> >
> >     Roberto
> >
> >
>
>
> --
>
> Roberto López López
> System Developer
> Parallab, Uni Computing
> +47 55584091
>
> --
> 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/5256A5E2.9020505%40uni.no.
> For more options, visit https://groups.google.com/groups/opt_out.
>



-- 
MLHIM VIP Signup: http://goo.gl/22B0U
============================================
Timothy Cook, MSc           +55 21 94711995
MLHIM http://www.mlhim.org
Like Us on FB: https://www.facebook.com/mlhim2
Circle us on G+: http://goo.gl/44EV5
Google Scholar: http://goo.gl/MMZ1o
LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook

-- 
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/CA%2B%3DOU3U69QzDSbc0qyJ_zbgA3BYHCi5zK3%3DaAra-saAq%2Bvj3EA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to