S
S
serik2018-02-06 15:03:28
Django
serik, 2018-02-06 15:03:28

After a while, an error appears on the site, what is the reason, django?

5a7998b831c9b214421018.png
I added a currency parser to the site, and everything seems to be working, but somehow after a time it is not displayed and an error pops up - "HTTP Error 302: The HTTP server returned a redirect error that would lead to an infinite loop. The last 30x error message was: Found"
urls.py

urlpatterns = [
    path('course/', views.dollar_evro, name='dollar_evro'),
]

views.py
def dollar_evro(request):
    id_dollar = "R01235"
    id_evro = "R01239"
    valuta = ET.parse(urllib.request.urlopen("http://www.cbr.ru/scripts/XML_daily.asp?date_req"))
    for  line in valuta.findall('Valute'):
        id_v = line.get('ID')
        if id_v == id_dollar:
            rub_dollar = line.find('Value').text
        if id_v == id_evro:
            rub_evro = line.find('Value').text
    today = datetime.date.today()
    return HttpResponse("<span class='main-header__currencies-val'>USD:</span><span id='dollar_vue'>" + rub_dollar +
    "</span><br><span class='main-header__currencies-val'>EUR:</span><span id='evro_vue'>" + rub_evro + "</span>" +
    "<script>var evro = evro_vue.innerHTML; evro = Number(evro.replace(',','.')).toFixed(2); evro_vue.innerHTML = evro;</script>" +
    "<script>var dollars = dollar_vue.innerHTML; dollars = Number(dollars.replace(',','.')).toFixed(2); dollar_vue.innerHTML = dollars;</script>")

Do not scold strongly for the ugly code, I did it in haste + a beginner

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question