I would to have a custom query to show a List of element in my admin django panel.
So, to have this I use a code like this:
class MyAdmin(admin.ModelAdmin):
....
def get_queryset(self, request):
return Post.objects.filter(author_type=AuthorType.USER)
This work well but I need also to add a LIMIT for this queryset:
class MyAdmin(admin.ModelAdmin):
....
def get_queryset(self, request):
return Post.objects.filter(author_type=AuthorType.USER)[:500]
But when I add the limit clause [:500]
I have this error:
Exception Value: Cannot reorder a query once a slice has been taken.
any suggestions?