Dear @KenWhitesell
I found a way to do that. In my models.py I added the following
I had to create the filed ‘location’ but honestly I do not rember if I add the value 6.000251769184164, 46.19337852885697 or 0.0,0.0
Now, if I look at the retirn value of my serializers.py, the return value is
{
"type": "FeatureCollection",
"features": [
{
"id": 1,
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
6.000251769184164,
46.19337852885697
]
},
"properties": {
"station_name": "st-1",
"station_lat": 46.187164,
"station_lng": 5.997526
}
},
{
"id": 2,
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
6.000251769184164,
46.19337852885697
]
},
"properties": {
"station_name": "st-2",
"station_lat": 46.173527,
"station_lng": 6.003618
}
},
{
"id": 3,
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
6.000251769184164,
46.19337852885697
]
},
"properties": {
"station_name": "st-3",
"station_lat": 46.186268,
"station_lng": 5.997424
}
},
{
"id": 4,
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
6.000251769184164,
46.19337852885697
]
},
"properties": {
"station_name": "st-4",
"station_lat": 46.173153,
"station_lng": 6.003011
}
},
{
"id": 5,
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
6.000251769184164,
46.19337852885697
]
},
"properties": {
"station_name": "st-5",
"station_lat": 46.187016,
"station_lng": 5.997001
}
},
{
"id": 6,
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
6.000251769184164,
46.19337852885697
]
},
"properties": {
"station_name": "st-6",
"station_lat": 46.173393,
"station_lng": 6.004297
}
},
{
"id": 7,
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
6.000251769184164,
46.19337852885697
]
},
"properties": {
"station_name": "st-7",
"station_lat": 46.186146,
"station_lng": 5.997017
}
},
{
"id": 8,
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
6.000251769184164,
46.19337852885697
]
},
"properties": {
"station_name": "st-8",
"station_lat": 46.172722,
"station_lng": 6.00308
}
},
{
"id": 9,
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
6.000251769184164,
46.19337852885697
]
},
"properties": {
"station_name": "st-9",
"station_lat": 46.184677,
"station_lng": 5.997972
}
},
{
"id": 10,
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
6.000251769184164,
46.19337852885697
]
},
"properties": {
"station_name": "st-10",
"station_lat": 46.182545,
"station_lng": 5.999088
}
},
{
"id": 11,
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
6.000251769184164,
46.19337852885697
]
},
"properties": {
"station_name": "st-11",
"station_lat": 46.185596,
"station_lng": 5.996834
}
},
{
"id": 12,
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
6.000251769184164,
46.19337852885697
]
},
"properties": {
"station_name": "st-12",
"station_lat": 46.182682,
"station_lng": 6.003728
}
},
{
"id": 13,
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
6.000251769184164,
46.19337852885697
]
},
"properties": {
"station_name": "st-13",
"station_lat": 46.184441,
"station_lng": 5.999066
}
},
{
"id": 14,
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
6.000251769184164,
46.19337852885697
]
},
"properties": {
"station_name": "st-14",
"station_lat": 46.172466,
"station_lng": 6.00361
}
},
{
"id": 15,
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
6.000251769184164,
46.19337852885697
]
},
"properties": {
"station_name": "st-15",
"station_lat": 46.17223,
"station_lng": 6.002607
}
},
{
"id": 16,
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
6.000251769184164,
46.19337852885697
]
},
"properties": {
"station_name": "st-16",
"station_lat": 46.183529,
"station_lng": 6.006996
}
},
{
"id": 17,
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
6.000251769184164,
46.19337852885697
]
},
"properties": {
"station_name": "st-17",
"station_lat": 46.172356,
"station_lng": 6.004136
}
},
{
"id": 18,
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
6.000251769184164,
46.19337852885697
]
},
"properties": {
"station_name": "st-18",
"station_lat": 46.179119,
"station_lng": 6.004328
}
},
{
"id": 20,
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
6.000251769184164,
46.19337852885697
]
},
"properties": {
"station_name": "st-20",
"station_lat": 46.182545,
"station_lng": 5.999088
}
},
{
"id": 21,
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
6.000251769184164,
46.19337852885697
]
},
"properties": {
"station_name": "st-21",
"station_lat": 46.185722,
"station_lng": 5.997623
}
},
{
"id": 22,
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
6.000251769184164,
46.19337852885697
]
},
"properties": {
"station_name": "st-22",
"station_lat": 46.17284,
"station_lng": 6.002612
}
},
{
"id": 23,
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
6.000251769184164,
46.19337852885697
]
},
"properties": {
"station_name": "st-23",
"station_lat": 46.184319,
"station_lng": 5.998923
}
},
{
"id": 24,
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
6.000251769184164,
46.19337852885697
]
},
"properties": {
"station_name": "st-24",
"station_lat": 46.184345,
"station_lng": 5.998887
}
},
{
"id": 25,
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
6.000251769184164,
46.19337852885697
]
},
"properties": {
"station_name": "st-25",
"station_lat": 46.183109,
"station_lng": 6.006879
}
},
{
"id": 26,
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
6.000251769184164,
46.19337852885697
]
},
"properties": {
"station_name": "st-26",
"station_lat": 46.183361,
"station_lng": 6.006943
}
},
{
"id": 27,
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
6.000251769184164,
46.19337852885697
]
},
"properties": {
"station_name": "st-27",
"station_lat": 46.217918,
"station_lng": 6.016133
}
},
{
"id": 28,
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
6.000251769184164,
46.19337852885697
]
},
"properties": {
"station_name": "st-28",
"station_lat": 46.217934,
"station_lng": 6.014958
}
},
{
"id": 29,
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
6.000251769184164,
46.19337852885697
]
},
"properties": {
"station_name": "st-29",
"station_lat": 46.217575,
"station_lng": 6.01465
}
},
{
"id": 30,
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
6.000251769184164,
46.19337852885697
]
},
"properties": {
"station_name": "st-30",
"station_lat": 46.217575,
"station_lng": 6.01465
}
},
{
"id": 31,
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
6.000251769184164,
46.19337852885697
]
},
"properties": {
"station_name": "st-31",
"station_lat": 46.184528,
"station_lng": 5.999068
}
},
{
"id": 32,
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
6.000251769184164,
46.19337852885697
]
},
"properties": {
"station_name": "st-32",
"station_lat": 46.183529,
"station_lng": 6.006996
}
},
{
"id": 33,
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
6.000251769184164,
46.19337852885697
]
},
"properties": {
"station_name": "st-33",
"station_lat": 46.183769,
"station_lng": 6.007091
}
},
{
"id": 34,
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
6.000251769184164,
46.19337852885697
]
},
"properties": {
"station_name": "st-34",
"station_lat": 46.183132,
"station_lng": 6.006629
}
},
{
"id": 35,
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
6.000251769184164,
46.19337852885697
]
},
"properties": {
"station_name": "st-35",
"station_lat": 46.183407,
"station_lng": 6.006712
}
},
{
"id": 36,
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
6.000251769184164,
46.19337852885697
]
},
"properties": {
"station_name": "st-36",
"station_lat": 46.183582,
"station_lng": 6.006712
}
},
{
"id": 37,
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
6.000251769184164,
46.19337852885697
]
},
"properties": {
"station_name": "st-37",
"station_lat": 46.183762,
"station_lng": 6.006895
}
},
{
"id": 38,
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
6.000251769184164,
46.19337852885697
]
},
"properties": {
"station_name": "st-38",
"station_lat": 46.183144,
"station_lng": 6.006361
}
},
{
"id": 39,
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
6.000251769184164,
46.19337852885697
]
},
"properties": {
"station_name": "st-39",
"station_lat": 46.183449,
"station_lng": 6.006433
}
},
{
"id": 40,
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
6.000251769184164,
46.19337852885697
]
},
"properties": {
"station_name": "st-40",
"station_lat": 46.183567,
"station_lng": 6.006497
}
},
{
"id": 41,
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
6.000251769184164,
46.19337852885697
]
},
"properties": {
"station_name": "st-41",
"station_lat": 46.183796,
"station_lng": 6.006625
}
},
{
"id": 42,
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
6.000251769184164,
46.19337852885697
]
},
"properties": {
"station_name": "st-42",
"station_lat": 46.183132,
"station_lng": 6.007131
}
}
]
}
That’s great because I see now all the markers, but in reallity I see only one marker because all markers are at the same place. This is because ‘geometry’ has alway the same value
"geometry": {
"type": "Point",
"coordinates": [
6.000251769184164,
46.19337852885697
]
},
I do not understand how the following works
def save(self, *args, **kwargs):
self.location = Point(float(self.station_lng), float(self.station_lat))
super(Stations, self).save(*args, **kwargs)
When the save() is called? Is should update the ‘location’ field with the station_lat and station_lng value, isn’t? Apparently, that does not work.
How can I update the ‘location’ field? By running ./manager.py migrate
?