2

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'
user1046162
  • 55
  • 1
  • 6

1 Answers1

12

you should add this line to models.py and don't import anything as models after that.

from django.contrib.gis.db import models

Ali
  • 6,808
  • 3
  • 37
  • 47