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

2019-01-25 Thread carlos
Thank Mike Dewhirst is working well Cheers On Fri, Jan 25, 2019 at 6:49 AM 'Amitesh Sahay' via Django users < django-users@googlegroups.com> wrote: > hi, > > All the above should work. If you are working on django REST, then you can > use ModelSerializer helper function. This will automatically

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

2019-01-25 Thread 'Amitesh Sahay' via Django users
hi,  All the above should work. If you are working on django REST, then you can use ModelSerializer helper function. This will automatically sync with the table fields, and if there are any foreign key and primary key. They would be mapped automatically.  Regards, Amitesh Sahay91-750 797 8619

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

2019-01-25 Thread Anirudh Jain
You can do this easily by creating creating an object of that model from which you want to get the value or input a value by using 'get_object_or_404' or 'get_list_or_404' by importing from django.shortucts. Reas about these two functions and difference between them in documentation. Use them, for

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

2019-01-25 Thread NAveeN Kumar Reddy
You can use this where you want you to link tables with foreign key models.ForeignKey(Model_Name,on_delete=models.CASCADE) That's it both tables will be in relation after migration of models into database On Fri, Jan 25, 2019 at 12:20 PM Mike Dewhirst wrote: > On 24/01/2019 5:28 pm, carlos

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

2019-01-24 Thread Mike Dewhirst
On 24/01/2019 5:28 pm, carlos wrote: 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

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

2019-01-23 Thread carlos
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) anot