Преобразование необработанного запроса в django orm

Я написал этот запрос в MySQL и запутался в преобразовании этого запроса в django orm

SELECT * FROM student.student_data 
where created_by in (select user_id from user_profile where user_location in(7, 8));

Это может помочь вам

query = UserProfile.objects.filter(user_location__in = [7,8])
student_data = Student.objects.filter(created_by = query)

Подробнее: [https://mattrobenolt.com/the-django-orm-and-subqueries/]

Вернуться на верх