我正在使用 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'
最佳答案
你应该将这一行添加到 models.py 并且之后不要导入任何模型。
从 django.contrib.gis.db 导入模型
https://stackoverflow.com/questions/8126627/