【问题标题】:Django-profiles, user profile with Geo field?Django-profiles,带有地理字段的用户配置文件?
【发布时间】:2011-11-14 18:56:13
【问题描述】:

我是第一次与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'

【问题讨论】:

  • from django.contrib.gis.db.models import PointField 并使用它

标签: geodjango django-profiles


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 2011-04-15
    • 2011-12-23
    • 2012-07-07
    • 1970-01-01
    • 2011-11-15
    • 1970-01-01
    • 2021-04-06
    • 2011-11-11
    • 2012-09-30
    相关资源
    最近更新 更多