> > but: > -------------------------------------------- > i'm testing 4 macs: Class A: 1mac , Class B: 2mac, Class C: 1mac > > when i define: > > class MacAdmin(admin.ModelAdmin): > def get_queryset(self, request): > qs = super(MACAdmin, self).get_queryset(request) > if request.user.is_staff and request.user.is_superuser: > return qs > return qs.filter(classi_id__mac=request.user) > > for make a test I create an user belogs to Class A and B so would be see 3 > macs on list_display > but only got 1 > > on debug mode, qs variable i can see the 4 macs, i need to know filter > it to get only that A and B because is filtered by user wich only belogs to > A and B class > > thanxs > > Not sure if I'm following you 100%, but i think you can filter like this:
return qs.filter(classi__prof=request.user) This would match the MAC to a class, and the class to a professor, and the professor to request.user. Should return all of the MAC's that belong to a class that request.user is a professor for, I believe. -James -- 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%2Be%2BciX5dK85Hxh0PYYpM9asBsP%3DerFp%2Bk-n3Y3%2BTe-wuX-5gQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.

