From cbd66e336a6aea77ff7be451ea38d5f4ad339388 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Wed, 13 Jun 2012 18:49:54 -0700 Subject: [PATCH] Use lat and lng to create a point on the userprofile instance. --- dp/profiles/forms.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/dp/profiles/forms.py b/dp/profiles/forms.py index ec5d28f..b7c1dfc 100644 --- a/dp/profiles/forms.py +++ b/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)