-2

I have:

Prof:AssociateProf:AssistantProf = x:y:z 

in database and I have to do these operations:

x/(x+y+z) :  y/(x+y+z) :  z/(x+y+z) 

in django.

Can anyone help me on this? Models.py is :

class Show(models.Model) :
Total = models.IntegerField(default = 0)
Prof = models.IntegerField(default = 0)
AssociateProf = models.IntegerField(default = 0)
AssistantProf = models.IntegerField(default = 0)
ResearchScholar = models.IntegerField(default = 0)
MTech = models.IntegerField(default = 0)
toti08
  • 2,448
  • 5
  • 24
  • 36
Mohan Goud
  • 169
  • 2
  • 12
  • Possible duplicate of [How to execute arithmetic operations between Model fields in django](https://stackoverflow.com/questions/45593440/how-to-execute-arithmetic-operations-between-model-fields-in-django) – Jorge Valentini Nov 13 '18 at 15:24

1 Answers1

0

Welcome to Stack Overflow . You could've added more details to your question.

You could access model's data using Django's Queryset and write custom functions in respective views and show them in respecive Views(html/templates) .

Refer to DjangoQuerySet for documentation about Django Queryset

and this was answered in another post : How to execute arithmetic operations between Model fields in django

SriSreedhar
  • 409
  • 5
  • 6
  • 1
    If you think a question is a duplicate then you should flag it as such. – Sayse Nov 13 '18 at 14:36
  • I tried like this: a = Show.objects.all for k in a : p = int(k.Prof) + int(k.AssociateProf) + int(k.AssistantProf). I didn't get and I dont understand how to get the individual elements . Can u pls help me on this – Mohan Goud Nov 14 '18 at 07:38