Hi, I was developing a experiment data management site adopting "django.contrib.admin". For example I have the "Carbon" model with a foreign key "author"
****************************************************** from django.db import models from django.contrib.auth import models as auth_mod class Carbon(models.Model): sn = models.CharField(max_length=30) source = models.CharField(max_length=30) pyrolysis_temperature = models.IntegerField(default=1400) pyrolysis_duration = models.IntegerField(default=2) comments = models.TextField(default='Leave your comments here') status = models.CharField(max_length=1, choices=STATUS_CHOICES,default='a') pub_date = models.DateTimeField('date produced', auto_now=True) author = models.ForeignKey(auth_mod.User, default=1) def __str__(self): return self.sn ******************************************************** and I write this in "carbon/admin.py" ******************************************************** class CarbonAdmin(admin.ModelAdmin): list_display = ('sn', 'source','pub_date','status') list_filter = ('source','status','pub_date',) exclude = ('author',) def save_model(self, request, obj, form, change): obj.author = request.user obj.save() def get_queryset(self, request): qs = super(CarbonAdmin, self).get_queryset(request) if request.user.is_superuser: return qs return qs.filter(author=request.user) ******************************************************** to achieve an "objective permission" to filter the carbons created by some specific author, *but this method failed to control the list_filter() result.* The list_filter() always feedback a list of the global options, other than the options only created by the author. How could I solve this by adding some filter before the list_filter() returning the global options? -- 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 django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/81c3c265-0eca-4c25-965a-f7f7278fb3b7%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.