Follow up question. Apologies for the continuation.

I tried integrating the API from OpenDOTA
https://api.opendota.com/api/heroes.

my code:

import requests
import json

url = requests.get('https://api.opendota.com/api/heroes')
res = url.json()

when I typed in 'res' in my terminal, it returns a List of dictionaries.
Now, is it possible to turn this list to a dictionary? Apologies for the
confusion, I am confuse as well.


Regards,
Jarvis




On Wed, Dec 27, 2017 at 2:41 AM, tango ward <[email protected]> wrote:

> Thanks for the idea Andréas. You're always helping me.
>
> On Wed, Dec 27, 2017 at 2:29 AM, Andréas Kühne <[email protected]
> > wrote:
>
>> All you need is to send the image (the url to the image) that should be
>> shown to the template, and then display it on the template. It shouldn't be
>> too hard as long as you understand how to send context data to the template.
>>
>> See here :
>> https://docs.djangoproject.com/en/2.0/topics/class-based-vie
>> ws/generic-display/#adding-extra-context
>>
>> Regards,
>>
>> Andréas
>>
>> 2017-12-26 19:07 GMT+01:00 tango ward <[email protected]>:
>>
>>> Hi Andréas,
>>>
>>> Thanks for the help.
>>>
>>> Also, I am not sure if the correct term is parse but I also want to
>>> display the images of heroes of DOTA 2 from OpenDOTA API. I saw a video on
>>> youtube on how to do it however its in Swift. Not sure if I can do it using
>>> CBV in django.
>>>
>>> On Wed, Dec 27, 2017 at 1:56 AM, Andréas Kühne <
>>> [email protected]> wrote:
>>>
>>>> Hi,
>>>>
>>>> If you want to parse json in django - or in python for that matter -
>>>> all you have to do is to use the json module.
>>>>
>>>> import json
>>>>
>>>> object = json.loads(insert_string_here)
>>>>
>>>> insert_string_here is the string that you want to parse - and object is
>>>> the parsed json.
>>>>
>>>> Look here for more information: http://docs.pytho
>>>> n-guide.org/en/latest/scenarios/json/
>>>>
>>>> Regards,
>>>>
>>>> Andréas
>>>>
>>>> 2017-12-26 18:29 GMT+01:00 tango ward <[email protected]>:
>>>>
>>>>>
>>>>> Hi,
>>>>>
>>>>> I need suggestions on this.
>>>>>
>>>>> I want to use the OpenDOTA API for my pet project. As a beginner, I
>>>>> don't know where to start working on this. I have found the OpenDOTA API
>>>>> https://api.opendota.com/api/heroes which I am planning to use but I
>>>>> am confuse as to how to parse the json into my CBVs. I read this article
>>>>> https://godjango.com/blog/working-with-json-and-django/ but it
>>>>> doesn't show how to work with json in CBV.
>>>>>
>>>>> What I would like to achieve is to display all heroes from the
>>>>> OpenDOTA api link into my template.
>>>>>
>>>>> Can anyone shed some light on where should I start?
>>>>>
>>>>>
>>>>> Regards,
>>>>> Jarvis
>>>>>
>>>>> --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "Django users" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>>> an email to [email protected].
>>>>> To post to this group, send email to [email protected].
>>>>> Visit this group at https://groups.google.com/group/django-users.
>>>>> To view this discussion on the web visit
>>>>> https://groups.google.com/d/msgid/django-users/CAA6wQL%2BFW8
>>>>> ZGjgCxX2MKNr9e8mmR6xvsmZwSTufTeEFB54tjrA%40mail.gmail.com
>>>>> <https://groups.google.com/d/msgid/django-users/CAA6wQL%2BFW8ZGjgCxX2MKNr9e8mmR6xvsmZwSTufTeEFB54tjrA%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>>>> .
>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Django users" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to [email protected].
>>>> To post to this group, send email to [email protected].
>>>> Visit this group at https://groups.google.com/group/django-users.
>>>> To view this discussion on the web visit https://groups.google.com/d/ms
>>>> gid/django-users/CAK4qSCc%3DD43bpYNUXj3NmAqk2kR_fNnNBvTocVWT
>>>> r44ioVT_mQ%40mail.gmail.com
>>>> <https://groups.google.com/d/msgid/django-users/CAK4qSCc%3DD43bpYNUXj3NmAqk2kR_fNnNBvTocVWTr44ioVT_mQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>>> .
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> To post to this group, send email to [email protected].
>>> Visit this group at https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit https://groups.google.com/d/ms
>>> gid/django-users/CAA6wQLJPZmUcG28g%3Dxw%3DWODVHzT06ir1SfQRsn
>>> TWUGBV8uBgJQ%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/django-users/CAA6wQLJPZmUcG28g%3Dxw%3DWODVHzT06ir1SfQRsnTWUGBV8uBgJQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To post to this group, send email to [email protected].
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit https://groups.google.com/d/ms
>> gid/django-users/CAK4qSCe5iKY3p_%2BjaRykG5ov4GjFBJbFaYmYLN7R
>> 0aet7hjbcQ%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAK4qSCe5iKY3p_%2BjaRykG5ov4GjFBJbFaYmYLN7R0aet7hjbcQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAA6wQLKD6gFcXLCb3uH8VnLwzwucs6HHh8Z0dy-V%3D-i3bo4WCg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to