Skip to content
Browse files

Use lat and lng to create a point on the userprofile instance.

  • Loading branch information...
1 parent 80a95d2 commit cbd66e336a6aea77ff7be451ea38d5f4ad339388 @chrisjones-brack3t chrisjones-brack3t committed Jun 13, 2012
Showing with 8 additions and 0 deletions.
  1. +8 −0 dp/profiles/forms.py
View
8 dp/profiles/forms.py
@@ -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.
Something went wrong with that request. Please try again.