为了账号安全,请及时绑定邮箱和手机立即绑定

我在我的 django 模型中添加位置字段它显示一个错误

我在我的 django 模型中添加位置字段它显示一个错误

Helenr 2021-12-21 16:05:31
当我尝试迁移它时,我试图在 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 版本


查看完整回答
反对 回复 2021-12-21
?
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


查看完整回答
反对 回复 2021-12-21
  • 2 回答
  • 0 关注
  • 304 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号