Commit 37621d4d authored by Gladys Forte's avatar Gladys Forte

Merge pull request #531 in RMS/api-main-service from gladys-dev2 to RMSv2

* commit '0e4f8c53':
  select_related
parents ca7d9461 0e4f8c53
...@@ -20,7 +20,10 @@ from django.db import IntegrityError ...@@ -20,7 +20,10 @@ from django.db import IntegrityError
class AllowedCompanyViewSet(viewsets.ModelViewSet): class AllowedCompanyViewSet(viewsets.ModelViewSet):
queryset = AllowedCompany.objects.all() # queryset = AllowedCompany.objects.all()
queryset = AllowedCompany.objects.select_related(
'id_number', 'company_pivot', 'group_pivots'
).all()
serializer_class = AllowedCompanySerializer serializer_class = AllowedCompanySerializer
pagination_class = CustomPagination pagination_class = CustomPagination
lookup_field = 'code' lookup_field = 'code'
......
...@@ -8,6 +8,7 @@ class ChangeRequestFormApproversSerializer( ...@@ -8,6 +8,7 @@ class ChangeRequestFormApproversSerializer(
): ):
def to_representation(self, instance): def to_representation(self, instance):
ret = super().to_representation(instance) ret = super().to_representation(instance)
print(instance)
try: try:
ret['company'] = { ret['company'] = {
"id": instance.user.department.company.id, "id": instance.user.department.company.id,
......
...@@ -11,7 +11,6 @@ class headers(serializers.ModelSerializer): ...@@ -11,7 +11,6 @@ class headers(serializers.ModelSerializer):
return ret return ret
class Meta: class Meta:
model = models.Company model = models.Company
fields = ( fields = (
......
...@@ -22,8 +22,6 @@ from django.conf import settings ...@@ -22,8 +22,6 @@ from django.conf import settings
from django.conf.urls.static import static from django.conf.urls.static import static
urlpatterns = [ urlpatterns = [
# path('admin/', admin.site.urls), # path('admin/', admin.site.urls),
path('api-auth/', include('rest_framework.urls')), path('api-auth/', include('rest_framework.urls')),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment