2

我是第一次使用django-profiles,所以我可能会遗漏一些基本的东西。

我想创建一个包含地理字段的 UserProfile 模型。具体来说是这样的:

class UserProfile(models.Model):
    user = models.OneToOneField(User)
    phone = PhoneNumberField()
    address = models.CharField(max_length=200)
    distance = models.IntegerField()
    zone = models.ForeignKey(Hood, null=True, blank=True)
    location = models.PointField(srid=900913, null=True, blank=True)
    objects = models.GeoManager()

我正在从 contrib.gis.db 导入模型,并从 auth 导入通用用户模型。

当我尝试运行 syncdb 时,出现以下错误:

AttributeError: 'module' object has no attribute 'PointField'
4

1 回答 1

12

您应该将此行添加到 models.py 中,之后不要将任何内容作为模型导入。

从 django.contrib.gis.db 导入模型

于 2011-12-09T07:39:07.087 回答