> I need to know how to filter in the django admin model License, the
> licenses of the user logged-in to the admin.
>
> class License(models.Model):
> user = models.ForeignKey('wiki.User')
> name = models.CharField(max_length = 100)
>
> def __unicode__(self):
> return self.name
>
> Example:
>
> So if Bob has created in the License Model 3 licenses, but John has
> created only two, then the model has 5 licenses total, but if Bob logs
> in to the admin he should only see his licenses (3 Licenses).
http://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.queryset
class MyModelAdmin(admin.ModelAdmin):
def queryset(self, request):
qs = super(MyModelAdmin, self).queryset(request)
if request.user.is_superuser:
return qs
return qs.filter(author=request.user)
> --
> 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+unsubscribe@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
>
Jason
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
No comments:
Post a Comment