Re: restricting choices of foreign key to objects owned by user

2012-01-13 Thread Kevin
You will need to alter the methods for the AdminModel:

https://docs.djangoproject.com/en/1.3/ref/contrib/admin/#django.contrib.admin.ModelAdmin.queryset

Your main focus will be the queryset method to limit what users can
see, this should also limit drop down boxes as well.  You may also
want to look at the formfield_for_* methods as well:

https://docs.djangoproject.com/en/1.3/ref/contrib/admin/#django.contrib.admin.ModelAdmin.formfield_for_foreignkey

These would be your starting point, there is also the permission ones
as well, which I do believe will limit the views using permissions.

On Jan 12, 6:17 am, kenneth gonsalves  wrote:
> hi
>
> note: this is in admin.
> I have a model called Child. Child has foreign key to Project. There are
> many projects, but each user is only allowed to add a child to the
> projects he belongs to. I have restricted the ProjectAdmin queryset so
> that the user can only see his projects in the project changelist. But
> when the user goes to add/edit a child, the dropdown shows *all*
> projects and not only the projects he belongs to. Any clues on how to
> achieve this?
> --
> regards
> Kenneth Gonsalves

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@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.



restricting choices of foreign key to objects owned by user

2012-01-12 Thread kenneth gonsalves
hi

note: this is in admin.
I have a model called Child. Child has foreign key to Project. There are
many projects, but each user is only allowed to add a child to the
projects he belongs to. I have restricted the ProjectAdmin queryset so
that the user can only see his projects in the project changelist. But
when the user goes to add/edit a child, the dropdown shows *all*
projects and not only the projects he belongs to. Any clues on how to
achieve this?
-- 
regards
Kenneth Gonsalves

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@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.