Вчера у меня была такая же проблема с этой простой моделью, и мне удалось ее решить.
Сегодня я изменил следующую модель :
from django.contrib.gis.db import models
from django.contrib.gis.geos import Point
from mapbox_location_field.models import LocationField
class IllegalDumpCategory(models.Model):
category = models.CharField(
max_length=50,
)
slug = models.SlugField(
max_length=50,
unique=True,
)
description = models.TextField(
max_length=500,
)
class IllegalDumpGeo(models.Model):
user_name = models.CharField(
'Username',
max_length=50,
)
user_name_email = models.EmailField(
'Email',
max_length=254,
)
description = models.TextField(
max_length=500,
)
image_1 = models.ImageField(
upload_to='%Y/%m/%d',
blank=False,
null=False,
)
image_2 = models.ImageField(
upload_to='%Y/%m/%d',
blank=True,
null=True,
)
image_3 = models.ImageField(
upload_to='%Y/%m/%d',
blank=True,
null=True,
)
volume_extension = models.PositiveIntegerField(
blank=False,
null=False,
)
link = models.URLField(
blank=True,
null=True,
)
waste_type = models.ForeignKey(
IllegalDumpCategory,
on_delete=models.CASCADE,
)
geom = models.PointField(
blank=True,
null=True,
)
location = LocationField()
def __int__(self):
return self.pk
def save(self, *args, **kwargs):
lat = self.location[0]
lon = self.location[1]
self.geom = Point(x=lon, y=lat, srid=4326)
super(IllegalDumpGeo, self).save(*args, **kwargs)
@property
def coordinates(self):
return str(self.geom.x) + ', ' + str(self.geom.y)
Я пытаюсь добавить некоторые пункты через панель администратора, но снова вижу эту ошибку:
ValueError could not convert string to float:
'6.01245266838146,-10.16992187499897'
Почему это происходит?
Traceback здесь