Hi, you might have better luck getting an answer on the GeoDjango mailing list: https://groups.google.com/forum/#!forum/geodjango
On Monday, May 25, 2020 at 11:06:26 AM UTC-4, Utkarsh Bansal wrote: > > I am facing problems while trying to use GeoDjango (v2.2) with MySQL 8.0.19 > > I created a new PointField and ran makemigrations > geo_code = PointField(srid=4326) > > On running sqlmigrate on the generated migration - I notice that the > column does not have a SRID constrain > BEGIN; > -- > -- Create model Location > -- > CREATE TABLE `locations_location` (`id` integer AUTO_INCREMENT NOT NULL > PRIMARY KEY, `geo_code` POINT NOT NULL); > CREATE SPATIAL INDEX `locations_location_geo_code_id` ON > `locations_location`(`geo_code`); > COMMIT; > > Now anything I add to the column is saved with SRID 0, which is incorrect. > > Next, I tried creating the column with the correct SRID by using > migrations.SeparateDatabaseAndState to generate the column. > ALTER TABLE backend_userprofile ADD COLUMN geocode_point POINT NULL SRID > 4326; > > Now if I try to insert data in this new column, I get and error because > Django is still trying to insert with SRID 0 and MySQL does not allow that > django.db.utils.OperationalError: (3643, "The SRID of the geometry does > not match the SRID of the column 'geo_code'. The SRID of the geometry is 0, > but the SRID of the column is 4326. Consider changing the SRID of the > geometry or the SRID property of the column.") > > Is there a way to make Django use correct SRIDs with MySQL? I also found a > ticket on the issue tracker which seems related > https://code.djangoproject.com/ticket/27464 > > > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/c9d4a387-de7e-42d5-897f-88cbd540fc1d%40googlegroups.com.

