I have two models, the second model is FK
from my first model like this:
class Model0(models.Model):
work = models.FloatField(blank=True, null = True)
class Model1(models.Model):
class Meta:
unique_together = (('lat', 'lng'),)
lng = models.FloatField(blank=True, null=True)
lat = models.FloatField(blank=True, null=True)
class Model2(models.Model):
idWork = models.ForeignKey('Model0', on_delete=models.CASCADE)
idSTFolio = models.OneToOneField('Model1', on_delete=models.CASCADE)
I use admin panel to add my data, I need that when I add a second (Model0, Model1) with others values to Model1, in my Model2 this association was created automatically like this:
for example:
Model2 : (Model0, Model1)
Id 1 : (1.5, (2.5, 3.0))
, 1.5 is 'Work' from Model0 and (2.5, 3.0) lat and lng in Model1
I need something like this...in this moment I create other Model1 with these values (2.5, 4.0), so like lat: 2.5
has already been added in Model2 I need that in my Model2 add other row like this automatically :
Id 1 : (1.5, (2.5, 3.0))
Id 2 : (1.5, (2.5, 4.0))
Any idea if it is possible to modify the admin panel for what I need? In this moment I must add this association in my Model2 page in admin panel, but It not is my idea.