當我嘗試遷移它時,我試圖在 postgis 擴展的幫助下向我的 django 模型添加一個位置字段,但錯誤顯示:django.db.utils.OperationalError:無法打開擴展控制文件“/usr/share/postgresql/10/extension/postgis.control”:沒有那個文件或目錄我已經更新了我的 settings.pyINSTALLED_APPS = [ 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'meenfee', 'accounts', 'rest_framework', 'rest_auth', 'rest_auth.registration', 'django.contrib.sites', 'allauth', 'django.contrib.gis', 'allauth.account', 'allauth.socialaccount', 'allauth.socialaccount.providers.facebook', 'allauth.socialaccount.providers.google', 'django.contrib.admin',] DATABASES = { 'default': { 'ENGINE': 'django.contrib.gis.db.backends.postgis', 'NAME': 'meenfeefinal', 'USER': 'meenfeefinaluser', 'PASSWORD': 'password', 'HOST': 'localhost', 'PORT': '', }}這是我的models.py。查看位置字段from django.contrib.gis.db import models as gis_modelsclass Service(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE) service_name = models.CharField(max_length=200,null=True,default="sample service") category = models.ForeignKey(Category, on_delete=models.CASCADE) subcategory = models.ForeignKey(SubCategory,on_delete=models.CASCADE) experience = models.TextField(blank=True,null=True) levelskill = models.CharField(max_length=120, choices=LEVELSKILLS) service_place = models.CharField(max_length=120, choices=LOCATION)我只是想成功地在我的服務模型中添加位置字段提前謝謝
2 回答

開滿天機
TA貢獻1786條經驗 獲得超13個贊
你的 postgres DB 缺少 postgis 插件
請使用以下命令安裝 postgis 擴展
sudo apt-get install postgis postgresql-9.3-postgis-scripts
請使用與您的 postgres db 相同的 postgis 版本

30秒到達戰場
TA貢獻1828條經驗 獲得超6個贊
sudo apt-get install postgis postgresql-11-postgis-scripts 給我:
The following packages have unmet dependencies:
postgis : Depends: libgdal20 (>= 2.0.1) but it is not installable
Depends: libproj12 (>= 4.9.0) but it is not installable
Recommends: postgresql-postgis
Recommends: postgis-doc but it is not going to be installed
然后,我嘗試成功:
sudo apt-get install postgresql-11-postgis-2.5-scripts
添加回答
舉報
0/150
提交
取消