Browse Source

pref: 修改创建 platform

pull/8873/head
ibuler 2 years ago
parent
commit
bb6b9e6f6e
  1. 2
      apps/perms/apps.py
  2. 4
      apps/users/serializers/group.py
  3. 4
      utils/generate_fake_data/resources/assets.py

2
apps/perms/apps.py

@ -10,5 +10,5 @@ class PermsConfig(AppConfig):
def ready(self):
super().ready()
from . import signal_handlers
# from . import signal_handlers
from . import notifications

4
apps/users/serializers/group.py

@ -47,7 +47,5 @@ class UserGroupSerializer(BulkOrgResourceModelSerializer):
@classmethod
def setup_eager_loading(cls, queryset):
""" Perform necessary eager loading of data. """
queryset = queryset.prefetch_related(
Prefetch('users', queryset=User.objects.only('id'))
).annotate(users_amount=Count('users'))
queryset = queryset.prefetch_related('users').annotate(users_amount=Count('users'))
return queryset

4
utils/generate_fake_data/resources/assets.py

@ -34,8 +34,8 @@ class PlatformGenerator(FakeDataGenerator):
tp = choice(self.category_type[category].choices)
data = {
'name': forgery_py.name.company_name(),
'category': choice(self.categories),
'type': tp
'category': category,
'type': tp[0]
}
platforms.append(Platform(**data))
Platform.objects.bulk_create(platforms, ignore_conflicts=True)

Loading…
Cancel
Save