[Fixed]-Formatting Django request cookies

1👍

You can use urllib to remove the characters described. See the code below.

import urllib
def submitcheckout(request):
    print(urllib.unquote(request.COOKIES['cart']))
👤Oli

0👍

Figured it out
first use urllib to convert it to normal text, then convert load json object using json.loads() function

import urllib
import json
def submitcheckout(request):
    result = urllib.unquote(request.COOKIES['cart'])
    json_result = json.loads(result)

Leave a comment