I am working in django project and need to use PointField imported from django.contrib.gis.db.models.
To use it, I installed GDAL by brew install gdal.
When I enter gdal-config --version in terminal after installing it, I got the message 3.3.1.
I believe this tells GDAL has been successfully installed.
I also updated the database setting in settings.py like this.
DATABASES = {
'default': {
"ENGINE": "django.contrib.gis.db.backends.mysql",
'NAME': config("DB_PROD_NAME"),
'USER': config("DB_USER"),
"PASSWORD": config("DB_PASSWORD"),
"HOST": config("DB_HOST"),
"PORT": config("DB_PORT")
},
}
And this is the models.py where PointField is used.
from django.contrib.gis.db import models
class Address(models.Model):
address_name = models.CharField(max_length=100)
address_name_detail = models.CharField(max_length=100)
address_type = models.CharField(max_length=11)
address_coord = models.PointField()
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
class Meta:
managed = False
db_table = 'address'
The problem is when I try python3 manage.py runserver or import the model Address in views.py,
I get an error django.core.exceptions.ImproperlyConfigured: Could not find the GDAL library (tried "gdal", "GDAL", "gdal3.2.0", "gdal3.1.0", "gdal3.0.0", "gdal2.4.0", "gdal2.3.0", "gdal2.2.0", "gdal2.1.0", "gdal2.0.0"). Is GDAL installed? If it is, try setting GDAL_LIBRARY_PATH in your settings.
By adding
GDAL_LIBRARY_PATH = config('GDAL_LIBRARY_PATH')
GEOS_LIBRARY_PATH = config('GEOS_LIBRARY_PATH')
in settings.py, there is no longer error when I enter python3 manage.py runserver, but it is not the case in importing Address model.
What can I do for this?
I am using M1 Mackbook Air. Can it be a problem?