That's quite easy -
___________
models.py:
    class num(models.Model):
        item = models.BigIntegerField(...)
___________
views.py:
    from . import models
    def funct(request):
        mdl = models.num.objects.get(id__exact=1)
        mdl2 = models.num.objects.get(id__exact=1)

        adds = int(mdl.item) + int(mdl2.item)
        dict = {"adds_temp" : adds}
        return render(request, "home.html", context=dict)

___________
templates/home.html

<pre>
  Addition: {{adds_temp}}
</pre>


On Tuesday, May 5, 2020, fahad rasool <rasoolfahad...@gmail.com> wrote:

> Can someone tell that how to perform an operation ,for example we retreive
> two numbers from database and want to add them and display on template in
> django
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/CACqgSmCzazz4W5AuwKOzgvyjSDAMb
> XwgD-B%3DkM%2BtG3T0t2Mb%3DQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CACqgSmCzazz4W5AuwKOzgvyjSDAMbXwgD-B%3DkM%2BtG3T0t2Mb%3DQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CALcUgYyh9G157%2BZb8XaM2nNc9fdUfHwejGTLJAB4XwpjQStNZQ%40mail.gmail.com.

Reply via email to