user1046162
user1046162

Reputation: 55

Django-profiles, user profile with Geo field?

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'

Upvotes: 2

Views: 3191

Answers (1)

Ali
Ali

Reputation: 6968

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

from django.contrib.gis.db import models

Upvotes: 12

Related Questions