Val
with pycharm as ide
inchidi
you know how to use python shell?
Lapanit ☃️
yes, kinda
inchidi
import requests
url = 'https://api.github.com/search/repositories?per_page=5&sort=created&q=men'
r = requests.get(url)
print r.json()
Lapanit ☃️
py2
Lapanit ☃️
eew
inchidi
hmm i dont know which library best for this
inchidi
Val
Val
Lapanit ☃️
inchidi
yeah but consider migrate to py3
Val
Val
got this after running it in my shell
inchidi
ah nice, then you can just put that inside your views.py
Val
Val
lols alright trying it out
Val
🙈🙈🙈 trial...
Val
i thought the 'men' in the url should be 'query'
inchidi
inchidi
you know how to concatenate string right?
Val
okay i have changed 'men' to query'
Val
yes i do
Val
"word" + str(23) + variable
inchidi
okay now you need to pass the r.json() to the template just like query
Val
okay
Val
{% if query %}
{{ r.json() }}
{% endif %}
using this same syntax?
inchidi
no, should be {{ dict_key }}
Val
no, should be {{ dict_key }}
pls explain ... unless you are saying that in the url from github there is a dictionary that r.json( ) is calling at
inchidi
look at the difference between 2 return there
inchidi
Val
Val
yes
inchidi
and the second one not
Val
inchidi
now you need to pass query and r.json() value
inchidi
do you know how to do that?
Val
concatenation?
Val
query + dict_key??? inside the if statement in the html🙈🙊
inchidi
no, add to the dict
{
'query':query,
'data':r.json()
}
inchidi
its just a python dictionary
Val
inchidi
yeah in the first render
Val
then that means i would have to add that also into the index.html as i did for the query
inchidi
true
Val
true
okay now i am beginning to get the logic here
inchidi
but this time you will not only check if 'data' exists
inchidi
we will iterate for every data value too
Val
okay! this is what i got when i refresh the page after inputing that
inchidi
nice thats our data
Val
Val
next iteration?
inchidi
umm am forgot how to call dict from template.
can you try change {{ data }} with {{ data.total_count }}
Val
okay
inchidi
okay perfect
Val
it gave the total numbers of characters
inchidi
nope, it gave the value of total_count from github api
inchidi
look at first line here after men {
Val
Val
Val
so what next😊??
inchidi
okay so github gave us items too. you can do
{% for repo in data.items %}
{{ repo.html_url }}
{% endfor %}
inchidi
it will show url of 5 selected repository from github
Val
its showing one at the moment
inchidi
no, thats 5 urls of github repository
Val
okay i see it now i was expecting to see a list
inchidi
so, this is html time
inchidi
if you want to make it looks better and more pretty
Val
Neo
inchidi
yeah, maybe
<div>
<a href="{{ repo.html_url }}">{{ repo.full_name }}</a>
<div>
up to you
Val
Neo
Lapanit ☃️
Neo
why
Neo
any spacial thing about silence
Lapanit ☃️
if I talk to much my admin status might wash away
Neo
ok