【问题标题】:I got this Error AttributeError: module 'django.contrib.gis.db.models' has no attribute 'GeoManager'我得到了这个错误 AttributeError: module 'django.contrib.gis.db.models' has no attribute 'GeoManager'
【发布时间】:2020-09-24 20:16:40
【问题描述】:
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' 没有属性 '地理管理器'

【问题讨论】:

标签: django model migrate makemigrations


【解决方案1】:

GeoManager has been removed.

似乎可以正常工作的解决方法:

在您的模型文件中导入:

from django.db.models import Manager as GeoManager

在您的模型类中:

objects = GeoManager()

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-01-11
    • 2022-12-01
    • 2014-12-20
    • 2021-12-12
    • 1970-01-01
    • 2012-02-29
    • 2022-10-05
    相关资源
    最近更新 更多