Skip to content

Commit

Permalink
Use lat and lng to create a point on the userprofile instance.
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisjones-brack3t committed Jun 14, 2012
1 parent 80a95d2 commit cbd66e3
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions dp/profiles/forms.py
Expand Up @@ -69,3 +69,11 @@ def __init__(self, *args, **kwargs):
self.fields["first_name"].initial = user.first_name
self.fields["latitude"].initial = self.instance.coords[0]
self.fields["longitude"].initial = self.instance.coords[1]

def save(self, *args, **kwargs):
"""
Use lat/lng values to create a POINT on the instance.
"""
self.instance.point = u"POINT(%f %f)" % (self.cleaned_data["longitude"],
self.cleaned_data["latitude"])
super(UserProfileForm, self).save(*args, **kwargs)

0 comments on commit cbd66e3

Please sign in to comment.