Re: How to operate with two models in one view?

2018-05-16 Thread Daniel Roseman
On Tuesday, 15 May 2018 12:21:26 UTC+1, Anton Smirnov wrote: > > I have two models: "Sensors" with information about its and "Measurments" . > > class Sensor(models.Model): > date_start = models.DateField() > Latitude = models.DecimalField(max_digits=18, decimal_places=15) > Longitude

Re: How to operate with two models in one view

2018-05-15 Thread Fidel Leon
When you are using models related by a Foreign Key, by default you have access to the "children" models from the parent model. For example, your Sensor model gets a "measurment_set" property just because of such foreign key: >>> dir(Sensor.objects.all()[0]) > > [other properties,

How to operate with two models in one view

2018-05-15 Thread Anton Smirnov
There are two models "Sensors" with information about them and "Measurments" . class Sensor(models.Model): date_start = models.DateField() Latitude = models.DecimalField(max_digits=18, decimal_places=15) Longitude = models.DecimalField(max_digits=18, decimal_places=15) def

How to operate with two models in one view?

2018-05-15 Thread Anton Smirnov
I have two models: "Sensors" with information about its and "Measurments" . class Sensor(models.Model): date_start = models.DateField() Latitude = models.DecimalField(max_digits=18, decimal_places=15) Longitude = models.DecimalField(max_digits=18, decimal_places=15) def