I am totally confused how to add math calculations in django to display on my page? I have absolutely no idea how to approach this. Thank you for your help :D
comment:
I am familiar with django, I have already made one app for myself in Django as well as in Flask, but that was to fill in tables on a page and write to a database, and now I want to make a program for sports plane calculations and I am stuck.... I don't know how to work with mathematical and physical data
I need practical tips on how to do this, not links to Djang's tutorial, although I am grateful for those too :D
calculate.py
from random import randint
import time
t = time.time()
class Calc:
def __init__(self):
pass
def position(self):
self.positionX = []
self.positionY = []
self.positionX.append([(randint(1, 100) * x) for x in range(1, 2, 1)])
self.positionY.append([(randint(1, 100) * y) for y in range(1, 2, 1)])
return self.positionX, self.positionY
def __str__(self):
return {self.positionX, self.positionY}
if __name__ == '__main__':
t = 0
while t < 20:
hear = Calc()
print('X: ', hear.position()[0], 'Y: ', hear.position()[1])
time.sleep(0.4)
t += 1
models.py
class CleanRobot(models.Model):
"""Robot Position and Speed Simulator"""
name = models.IntegerField(choices=CHOOSE)
velocity = models.FloatField(null=True, blank=True)
positionX = models.FloatField(null=True, blank=True)
positionY = models.FloatField(null=True, blank=True)
angleTHETA = models.FloatField(null=True, blank=True)
class Meta:
verbose_name = "CleanRobot"
verbose_name_plural = "CleanRobots"
def __str__(self):
return self.name
views.py # @method_decorator(login_required, name='dispatch') class CleanRobotView(View): '''... '''
def get(self, request):
return render(request, Calc())
forms.py
class Robo(forms.ModelForm):
"""New note add form"""
class Meta:
model = CleanRobot
fields = '__all__'
html
{% block title %}Robot{% endblock %}
{% block content %}
<form method="POST">
{% csrf_token %}
{{ positionX }}
{# <input type="submit" class="btn btn-second btn-lg" value="Wyślij">#}
</form>
<button type="button" class="btn btn-primary btn-lg"><a href="{% url 'menu' %}">Powrót</a></button>
{% endblock %}