Hello.
Wrote the simplest application for calculating body mass index. Everything works fine until a certain point, and then an error begins to appear
"ValueError at / The view indexmassi.views.indexmassi didn't return an HttpResponse object. It returned None instead."
It is solved only by replacing lines with POST lines with forcibly indicated values of weight and height. Then the page is displayed norms and then return back.
The pattern can not reveal. Usually every 4-6 hours such garbage, only it worked, I press F5 and that's it. Today I reinstalled the system, launched the project and immediately got out.
views.py is:
from django.shortcuts import render from .forms import Forma def indexmassi(request): if request.method == "POST": forma = Forma(request.POST) ves = float(request.POST.get("ves")) rost = float(request.POST.get("rost")) im = round(float(ves/((rost * rost) / 10000)), 1) if 1 <= im < 16: opisanie = "Выраженный дефицит массы" elif 16 < im <= 18.5: opisanie = "Недостаточная масса тела" elif 18.5 < im <= 25: opisanie = "Вы нормальный" elif 25 < im <= 30: opisanie = "Избыточная масса тела (предожирение)" elif 30 < im <= 35: opisanie = "Ожирение 1-ой степени!" elif 35 < im <= 40: opisanie = "Ожирение 2-ой степени!" elif im > 40: opisanie = "Ожирение 3-ой степени!" else: opisanie = "Некорректный результат!" return render(request, 'indexmassi/index.html', {"forma": forma, "message": format(im), "opisanie": opisanie})