Django-profiles,带有地理字段的用户配置文件?
我第一次使用 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'
I am working with django-profiles for the first time, so I might be missing something basic.
I'd like to create a UserProfile model that includes geographic fields. Specifically something along these lines:
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()
I'm importing models from contrib.gis.db, and also importing the generic User model from auth.
when I try to run syncdb, I get the following error:
AttributeError: 'module' object has no attribute 'PointField'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该将此行添加到 models.py 中,并且之后不要将任何内容导入为模型。
从 django.contrib.gis.db 导入模型
you should add this line to models.py and don't import anything as models after that.
from django.contrib.gis.db import models