I have a Django application that uses some geographic information. I have installed GDAL and installed Spatialite by downloading the windows binaries and placing them in my python directory (conda environment in my case) as detailed in this post. That was the only way I was able to get it to work without throwing an error.
My database is set in settings.py as
DATABASES = {
'default': {
# 'ENGINE': 'django.db.backends.sqlite3',
'ENGINE': 'django.contrib.gis.db.backends.spatialite',
'NAME': BASE_DIR / 'db.sqlite3',
}
}
When I try to test a query based on geographic coordinates such as
loc = Point(location['lng'], location['lat'])
radius = D(mi=20)
queryset = BusinessProfile.objects.filter(businessAddress__coordinates__dwithin=(loc, 2.0)) \
.filter(businessAddress__coordinates__distance_lte=(loc, radius)) \
.annotate(distance=Distance("businessAddress__coordinates", loc)) \
.order_by("distance")
I get the following error:
django.db.utils.OperationalError: no such function: lwgeom_version
I have already installed GDAL and spatialite, can anyone help me figure out what the problem could be here?
EDIT: I’ve confirmed that GEOS, PROJ, and GDAL are installed - I have spatialite installed as I stated previously, still I have the same issue where GeoDjango can not find the function lwgeom_version, I assume that this is an issue with my spatialite installation but I’m unsure why when I downloaded binaries from the source page.