M
M
maestro072017-04-11 12:58:03
Django
maestro07, 2017-04-11 12:58:03

How to output json result to html?

<div class="col-md-4">
          <div class="contest_list">
            <h3>Список контестов</h3>
            <div class="list">						
              <p>Codeforces Round #407 (Div. 1)</p>
              <p><a href="">27.03.2017 20:35 UTC+6</a></p>
              <p><a href="">ссылка</a></p>
              <hr>
            </div>
            <div class="list">						
              <p>Тренировка №9 для начинающих программистов</p>
              <p><a href="">01.04 Sat 15:15</a></p>
              <p><a href="">ссылка</a></p>
              <hr>
            </div>
          </div>
        </div>

here I need to display the json result, more precisely name, href and start (date)
def getContestList():
    now = datetime.datetime.now()
#    2017-04-10T00%3A00%3A00
#    print now.isoformat()
    url_params = urllib.urlencode({'start_gte': now.isoformat(), 'offset':'100' })
#    print url_params

    r = requests.get('...'+url_params)
    response = r.json()
#    print response
#    for obj in response["objects"]:
#        print obj["href"]

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Astrohas, 2017-04-11
@Astrohas

return HttpResponse(your_json)
like so?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question