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.")