# How can i get info about parent task in python code?

**URL:** <https://forum.asana.com/t/how-can-i-get-info-about-parent-task-in-python-code/146134>\
**Category:** API & Developers\
**Tags:** api, subtasks, tasks, projects\
**Created:** [13 December 2021 13:16 UTC](https://forum.asana.com/t/how-can-i-get-info-about-parent-task-in-python-code/146134 "2021-12-13T13:16:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aaoam](https://luna1.co/8d76cd.png) [@Aaoam](https://forum.asana.com/u/Aaoam)\
**Post date:** [13 December 2021 13:16 UTC](https://forum.asana.com/t/how-can-i-get-info-about-parent-task-in-python-code/146134/1 "2021-12-13T13:16:10Z")

</div>

I couldn’t find the answer I needed in the documetation. I have in my code opt fields like this opt\_fields=[“memberships.project.name”,“memberships.section.name”,“parent.name”,“memberships.project”,“name”,“permalink\_url”].  
So first of all i get project’s name, section’s name, then i get parent’s name. Can i get parent’s info? I need section and project.  
Do I understand correctly or not: In my opt fields I get info about task or sub-task? If I get task’s name then I can get only parent’s name and nothing else?  
At actually i want something like that:

1. project’s name of task
2. section’s name of task
3. if i have parent task i want get parent task’s name
4. project’s name of parent task
5. finally section’s name of parent task.  
I will be very grateful if you can help me!

---

<div class="post-metadata">

**Author:** ![Frederic\_Malenfant](https://sea2.discourse-cdn.com/asana/user_avatar/forum.asana.com/frederic_malenfant/32/8358_2.png) [@Frederic\_Malenfant](https://forum.asana.com/u/Frederic_Malenfant)\
**Post date:** [13 December 2021 14:11 UTC](https://forum.asana.com/t/how-can-i-get-info-about-parent-task-in-python-code/146134/2 "2021-12-13T14:11:06Z")

</div>

Hi @Aaoam , welcome to the forum!

You are very near the information you need.

Because a subtask and its parent are both tasks, you only need to query the same fields for the parent, as you can do for the subtasks when you query the parents.

Example:  
/tasks/xyz (xyz IS a subtask)  
opt\_fields: “name, memberships.project, memberships.section, parent.name, parent.memberships.project, parent.memberships.section”

Subtasks can be 5 levels deep, so they can have their own memberships, + multi-level parent memberships. And each level can be member of 0, 1 or many projects.

Now, what are you querying? Usually, you request tasks, and their subtasks. And, if you know the parent task, you don’t need to query the parent memberships of subtasks, because you already know them from its parent.

Except, if you assign that subtask to a a user, tag or project directly. Then you can see that subtask in the results of a project or user or tag query, like /projets/xyz/tasks. In that case, I understand that you may need to query more informations about its parent.

p.s. I was curious, so I tried with a 5-level deep subtask I have in my account… and it works, we can query 5 level parent in one call!  
using that opt\_field config:  
name,  
parent.name,  
parent.parent.name,  
parent.parent.parent.name,  
parent.parent.parent.parent.name,  
parent.parent.parent.parent.parent.name,  
parent.parent.parent.parent.parent.memberships.project

!!  
But I don’t suggest to use that in a real application.

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/asana/user_avatar/forum.asana.com/system/32/276370_2.png) [@system](https://forum.asana.com/u/system)\
**Post date:** [30 May 2025 19:04 UTC](https://forum.asana.com/t/how-can-i-get-info-about-parent-task-in-python-code/146134/3 "2025-05-30T19:04:52Z")

</div>

Closed on 30 May 2025 19:04 UTC


