PointField(required=True)
class Meta:
model = User
fields = ('uid', 'email', 'first_name', 'last_name', 'avatar', 'position' )
Возвращает нечто подобное
{
"uid": "ca332d17-4c39-44dc-b3f6-03b71909f8ee",
"email": "qwe@qweqwe.qwe",
"first_name": "MEGA",
"last_name": "MEGA",
"avatar": "http://localhost:8000/api/cat_V4cQbdZ.jpg",
"position": {
"latitude": "49.83968300000001",
"longitude": "24.029717000000005"
}
},
position = serailizer.SerializerMethodField() def get_position(self, obj) return 'POINT(%s;%s)' % (obj.position.x, obj.position.y)
Обсуждают сегодня