import json from django.core.management.base import BaseCommand from polls.models import servers, count #x is bytes output def myparser(x): res=x.content print(x.content) print(type(x.content)) parsed= res.decode() #convert to string print(type(parsed)) decoded = json.loads(parsed) print(json.dumps(decoded, sort_keys=True, indent=4)) return decoded