I have 2 pretty basic Django models: User and UserProfile. I am using the REST framework and would like to include profile information when retrieving all users. I have searched the internet but was not able to find the answer. This is what I am currently trying: User.objects.all().prefetch_related('userprofile')
What I am trying to return is something like:
[
{'email': 'email@example.com',
'first_name': 'Test',
'last_name': 'McTester'},
{'email': 'user2@example.com',
'first_name': 'Mary',
'last_name': 'McPherson'}
]
where first and last name are profile attributes. I have been able to do something similar using Flask and GraphQL but was wondering if this is possible with REST in Django.