# Float field question

**URL:** <https://forum.djangoproject.com/t/float-field-question/4107>\
**Category:** Using Django\
**Created:** [August 28, 2020, 11:13pm UTC](https://forum.djangoproject.com/t/float-field-question/4107 "2020-08-28T23:13:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![joff13](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/joff13/32/1957_2.png) [@joff13](https://forum.djangoproject.com/u/joff13)\
**Post date:** [August 28, 2020, 11:13pm UTC](https://forum.djangoproject.com/t/float-field-question/4107/1 "2020-08-28T23:13:31Z")

</div>

Hi everyone  
Just a silly question. How can I retrieve value from models. floatfiled and make operations?

Example

F1 = models.FloatField ()  
F2 = models.FloatField (default = 3.765)  
F3 = models.FloatField ()

Not working  
Python will redefine variable

F1 = 5.788

Not working

F1 = F2 + F3

Not working anything like  
F2.value

I have to get float valus from some Models, make some operation as a float And stor it again in another model as floafied

Thanks a lot for suggestions

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [August 28, 2020, 11:25pm UTC](https://forum.djangoproject.com/t/float-field-question/4107/2 "2020-08-28T23:25:29Z")

</div>

You don’t retrieve the value from a model. The model is just the template. You retrieve values from instances of the model.

If you would please provide more details of the code you’re trying to run, in the context in which you’re running it, we might be able to provide more tangible assistance.

---

<div class="post-metadata">

**Author:** ![joff13](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/joff13/32/1957_2.png) [@joff13](https://forum.djangoproject.com/u/joff13)\
**Post date:** [August 29, 2020, 12:06am UTC](https://forum.djangoproject.com/t/float-field-question/4107/4 "2020-08-29T00:06:35Z")

</div>

Hi Ken thanks for quick answer.  
(i know difference from a class and his instance)

for a moment i thought was possible to do that

```
class mymodel (models.Model):
     val1 = models.FloatField ()
     val2 = models.FloatField ()
     val3 = models.FloatField ()
     val3 = val2 - val1

```

but correct way should be something like  
( if you kindly could confirm an correct )

```
class mymodel (models.Model):
     val1 = models.FloatField ()
     val2 = models.FloatField ()
     val3 = models.FloatField ()
     def save(self, *args, **kwargs):
         self.val3 = self.val2 - self.val1
         super().save(*args, **kwargs)

```

it’s 2 in the morning for me… i’m getting tired

thanks again for your help

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [August 29, 2020, 12:09am UTC](https://forum.djangoproject.com/t/float-field-question/4107/5 "2020-08-29T00:09:17Z")

</div>

Yep, that’s the basic idea.
