I am trying to create a Django admin filter that will get random groups of users. At this point, I have two problems:
- Applying a custom filter to the User model, and
- Displaying a random set of users.
On #1, I've tried using User.username.random_filter = True
, but it comes back with an AttributeError saying that User has no attribute username
.
On #2, I know I can get 50 random users with User.objects.order_by('?')[:50]
, but I have not been able to figure out how to get the result of such a query to show up in the admin listing. As far as I can tell, the listing is generated by the URL's GET request, but I've not had any luck ordering with it.
Any suggestions?