mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Improve DB efficiency for user settings (#6996)
- Prefetch related user - Prevents 1+N issue
This commit is contained in:
parent
1e0382c719
commit
f61259e0d2
@ -258,6 +258,13 @@ class UserSettingsList(SettingsList):
|
||||
common.models.InvenTreeUserSetting.build_default_values(user=request.user)
|
||||
return super().list(request, *args, **kwargs)
|
||||
|
||||
def get_queryset(self):
|
||||
"""Return prefetched queryset."""
|
||||
queryset = super().get_queryset()
|
||||
queryset = queryset.prefetch_related('user')
|
||||
|
||||
return queryset
|
||||
|
||||
def filter_queryset(self, queryset):
|
||||
"""Only list settings which apply to the current user."""
|
||||
try:
|
||||
|
Loading…
Reference in New Issue
Block a user