Home > OS >  How to get a value from the result of queryset and assign it
How to get a value from the result of queryset and assign it

Time:09-16

How to get a value from the result of queryset and assign it

I've got a result of queryset

<QueryDict: {'payment_id': ['KIAhwplaq0qgx8'], 'pay_order_id': ['order_KIAhsgbBDXth83'], 'result': ['5e5ab4f08a09915aa4791d25315b565beb62efe52fae71de877e2818d266f538']}>

I want those values to be assigned like this

payment_id = 'KIAhwplaq0qgx8'
pay_order_id = 'order_KIAhsgbBDXth83'
result = '5e5ab4f08a09915aa4791d25315b565beb62efe52fae71de877e2818d266f538'

Even the queryset code to get a value AND ASSIGNING IT IS FINE BUT i Don't KNOW How. If anyone knows. Please share it. It would be Helpful

CodePudding user response:

It is not a QuerySet, but a QueryDict object (more like an extended version of dict)

So, you can assign the values to variables like,

payment_id = my_qd_object["payment_id"]
pay_order_id = my_qd_object["pay_order_id"]
result = my_qd_object["result"]
  • Related