Calculating functions with python / django
I'm building a python / django portfolio and i'm having a very hard time with one of my Gym / BMI calculator.
I'm trying to have a user input their current Weight and Height, so they can have a BMI result that will be visible from the frontend, and then POST and saved from the Backend models.
I just don't know how to include a .py class that i created that will allow the user to input those details from the models and have calculation done in the frontend from the input textfield.
Please help...:-)
`
from django.db import models
# Create your models here. (<-- This is my Model, where i'll save the calculation)
class BMI(models.Model):
Name = models.CharField(max_length=50)
Surname = models.CharField(max_length=50)
Weight = models.IntegerField()
Height = models.IntegerField()
def __str__(self):
return self.Name
# Create your forms here. (<-- This is my form, where user will be inputting their Weight and Height)
from django import forms
from django.forms import ModelForm
from . models import BMI
class BMIForm(ModelForm):
class Meta:
model = BMI
fields = ['Weight', 'Height']
`
from django.shortcuts import render
from . models import BMI
from . forms import BMIForm
# Create your views here.
def Home(request):
BMIOutcome = BMIForm
return render(request, 'Experiment/Home.html',
{'BMIOutcome':BMIOutcome})
I have decided the best outcome will be to use Javascript for that kind of calcualation.