Wednesday, January 23, 2019

how can I reference a field from one model to another model

Hello, 
I do not know if I'm asking the question correctly, but I need to call a field of one model in another model
example:
class ModelDad(models.Model):
    name = blablabla

class ModelChild1(....):
   fk(ModelDad)
   number = models.IntegerField()

class ModelChild2(....):
  fk(ModelDad)
  another_number = models.IntegerField()

   def make_proces(self):
      return self.another_number * ModelChild1.number #this is my question

how can I send a call number within the function (make_proces ) of ModelChild2

is posible????



--
att.
Carlos Rocha

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAM-7rO125r3pox%3D137GOfmjnmFaf3cekaNj-j%2B9A0Cwc%3DEM0Fg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment