diff --git a/api/dashboard/profile/profile_serializer.py b/api/dashboard/profile/profile_serializer.py index abe8db9d..ad37137d 100644 --- a/api/dashboard/profile/profile_serializer.py +++ b/api/dashboard/profile/profile_serializer.py @@ -73,16 +73,10 @@ def get_college_id(self, obj): return user_org_link.org.id if user_org_link else None def get_org_district_id(self, obj): - org_type = ( - OrganizationType.COMPANY.value - if MainRoles.MENTOR.value in self.get_roles(obj) - else OrganizationType.COLLEGE.value - ) - user_org_link = obj.user_organization_link_user.filter( - org__org_type=org_type - ).first() - - return user_org_link.org.district.id if (user_org_link and user_org_link.org.district) else None + org_type = OrganizationType.COMPANY.value if MainRoles.MENTOR.value in self.get_roles( + obj) else OrganizationType.COLLEGE.value + user_org_link = obj.user_organization_link_user.filter(org__org_type=org_type).first() + return user_org_link.org.district.id if user_org_link and hasattr(user_org_link.org, 'district') else None def get_college_code(self, obj): if user_org_link := obj.user_organization_link_user.filter(