fix
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
import hashlib
|
import hashlib
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import random
|
|
||||||
import re
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
import smtplib
|
import smtplib
|
||||||
@@ -298,9 +297,8 @@ class RandomUsernameAPI(APIView):
|
|||||||
return self.error("需要班级号")
|
return self.error("需要班级号")
|
||||||
usernames = User.objects.filter(username__istartswith=classroom).values_list(
|
usernames = User.objects.filter(username__istartswith=classroom).values_list(
|
||||||
"username", flat=True
|
"username", flat=True
|
||||||
)
|
).order_by("?")
|
||||||
random.shuffle(usernames)
|
if len(usernames) > 10:
|
||||||
if len(usernames) >= 10:
|
|
||||||
return self.success(usernames[:10])
|
return self.success(usernames[:10])
|
||||||
else:
|
else:
|
||||||
return self.success(usernames)
|
return self.success(usernames)
|
||||||
|
|||||||
Reference in New Issue
Block a user