django - 我得到了这个错误 AttributeError: module 'django.contrib.gis.db.models' has no attribute 'GeoManager'
问题描述
This Is My Models :
class Intervention(models.Model):
Titre_intervention = models.TextField(max_length=255)
date_intervention = models.DateField(auto_now_add=True)
type_panne = models.ForeignKey(Panne,on_delete=models.CASCADE)
etat = models.CharField(max_length=30)
description = models.TextField(max_length=255)
image = models.ImageField(blank=True,null=True,upload_to='medial/%Y/%m/%D')
equipements = models.ManyToManyField(Equipement)
clients = models.ForeignKey(Client,on_delete=models.CASCADE,default=True)
location = models.PointField(srid=4326)
objects = models.GeoManager()
这就是我进口的:
from __future__ import unicode_literals
from django.db import models
from django.contrib.gis.db import models
所以当我运行 Makemigrations 我得到错误:
AttributeError:模块“django.contrib.gis.db.models”没有属性“GeoManager”
解决方案
似乎可以正常运行的解决方法:
在您的模型文件中导入:
from django.db.models import Manager as GeoManager
在您的模型类中:
objects = GeoManager()
推荐阅读
- sql-server - 使用 T-SQL 填充缺失的行
- django - Django 到 Angular 6:CSRF 令牌丢失或不正确,即使它已在标头中设置
- php - 如何在跟踪数据集更改的同时最好地构建数据库
- javascript - 使用 render props 函数将上下文中的表单名称传递给 Redux Form formValueSelector
- ruby - Ruby JSONP 返回 Errno::EPROTONOSUPPORT
- postgresql - 通过 Powershell Start-Transcript 将时间戳添加到 Postgres PSQL 执行输出
- vue.js - 作用于从 JSON 构建的 Vue 中的单个输入
- php - Mariadb 一遍又一遍地重复查询
- reactjs - 用css模块反应js添加类
- php - PHP 无法上传视频和音频文件