如何向Django ManyToManyField发出发布请求? (杰森·阵列)

时间:2019-05-31 15:06:25

标签: django post django-rest-framework many-to-many postman

我有一个API,其中包含其他所有对象的数组,这些对象都有一个名称,如下所示:

[
{
    "id": 1,
    "title": "Push Workout Bjarred",
    "description": "Kör Hårt!",
    "exercises": [
        {
            "name": "Tricep Cable Pushdown"
        },
        {
            "name": "Delt Side Raises"
        },
        {
            "name": "Delt Barbell Press"
        },
        {
            "name": "Chest Cable Flyes"
        },
        {
            "name": "Barbell Bench Press"
        }
    ],
    "cardio": [
        {
            "name": "Stairmaster",
            "time": 12
        }
    ]
},
{
    "id": 2,
    "title": "Pull Workout Loddekopinge",
    "description": "",
    "exercises": [
        {
            "name": "Bicep Cable Curl"
        },
        {
            "name": "Back Barbell Row"
        },
        {
            "name": "Back Pullback Machine"
        }
    ],
    "cardio": [
        {
            "name": "Bike",
            "time": 10
        }
    ]
}
]

我如何发出包含要包括哪些练习的帖子请求? 这些练习来自另一个Api(假设我在本地有这些练习,我之前已经发出了获取请求以获取它们)-可以说我从列表中选择了练习并将它们添加到参数中以发出发布请求!

如果有人可以在任何类型的帖子请求中显示如何执行此操作,则将有助于加载,邮递员,拍打,Xcode等(其他...)

0 个答案:

没有答案