I'm trying to create a code which calculates the Normal density using 3 numeric inputs. I tried to run the following code, but the website does not receive inputs and jumps to the the last comment, 'Thank you.' How could I fix it? Thanks in advance!
from django.shortcuts import render
from django import forms
from django.http import *
from scipy.stats import norm
n1 = forms.FloatField(label = 'Input a Number')
n2 = forms.FloatField(label = 'Mean')
n3 = forms.FloatField(label = 'SD')
if request.method == 'POST':
form = NF(request.POST)
number = form.clean_data['n1']
mean = form.clean_data['n2']
sd = form.clean_data['n3']
density = norm.pdf(number, mean, sd)
html= '<html><body>The density is %s.</body></html>' % density
I think it's maybe because you don't return what you get but only a Thanks.
Change last line to this:
... html= '<html><body>The density is %s.</body></html>' % density return HttpResponse(html) ...