django SRID conflict between django and mysql

hi,
i have this issue after updating srid on my mysql database from srid 0 to srid 3857
when i save new entry this exception occured

Exception Type: OperationalError
Exception Value: (3643, “The SRID of the geometry does not match the SRID of the column ‘location’. The SRID of the geometry is 0, but the SRID of the column is 3857. Consider changing the SRID of the geometry or the SRID property of the column.”)

how can i fix this issue
and thank you all

Hi :waving_hand:

Unfortunately, GeoDjango never caught up with MySQL’s support for SRID in column definitions.

There’s a ticket for adding support and a roadmap that I just outlined: #27464 (SRID should be stored in DB on MySQL backend) – Django

MySQL expects the point’s SRID to match the column. Make sure your model field has srid=3857 set, and pass srid=3857 whenever creating the Point object:

Python
from django.contrib.gis.geos import Point

point = Point(x, y, srid=3857)
For existing objects, just set obj.location.srid = 3857 before saving.