I have followed this documentation, however, when I run the documentation example, I get the error message at the end of the code block below:
>>> from django.contrib.gis.geos import GEOSGeometry, Point
>>> pnt = Point(954158.1, 4215137.1, srid=32140)
>>> pnt = GEOSGeometry('SRID=32140;POINT(954158.1 4215137.1)')
>>> qs = WorldBorder.objects.filter(mpoly__intersects=pnt)
>>> print(qs.query)
SELECT "world_worldborder"."id", "world_worldborder"."name", "world_worldborder"."area", "world_worldborder"."pop2005", "world_worldborder"."fips", "world_worldborder"."iso2", "world_worldborder"."iso3", "world_worldborder"."un", "world_worldborder"."region", "world_worldborder"."subregion", "world_worldborder"."lon", "world_worldborder"."lat", "world_worldborder"."mpoly"::bytea FROM "world_worldborder" WHERE ST_Intersects("world_worldborder"."mpoly", ST_Transform(ST_GeomFromEWKB('\001\001\000\000 \214}\000\0003333\\\036-AfffFX\024PA'::bytea), 4326))
>>> qs
Traceback (most recent call last):
File "C:\Users\USER\Documents\Internships\Kodecamp\geodjango_tutorial\proj-venv\lib\site-packages\django\db\backends\utils.py", line 85, in _execute
return self.cursor.execute(sql, params)
psycopg2.errors.InternalError_: could not form projection (PJ) from 'srid=32140' to 'srid=4326'
The project’s requirements.txt file is:
asgiref==3.4.1
Django==4.0
sqlparse==0.4.2
tzdata==2021.5
psycopg2==2.9.2
I have also installed PostGIS; and PROJ, GDAL and GEOS libraries.