How to limit queryset/the records to view in Django admin site?

In your admin definition, you can define a queryset() method that returns the queryset for that model’s admin. eg: class MyModelAdmin(admin.ModelAdmin): def queryset(self, request): qs = super(MyModelAdmin, self).queryset(request) return qs.filter(user=request.user) Then only objects with user=request.user will be visible in the admin.

aggregate() vs annotate() in Django

I would focus on the example queries rather than your quote from the documentation. Aggregate calculates values for the entire queryset. Annotate calculates summary values for each item in the queryset. Aggregation >>> Book.objects.aggregate(average_price=Avg(‘price’)) {‘average_price’: 34.35} Returns a dictionary containing the average price of all books in the queryset. Annotation >>> q = Book.objects.annotate(num_authors=Count(‘authors’)) >>> … Read more