forked from caioariede/django-location-field
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f8fdaa0
commit a378571
Showing
5 changed files
with
53 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,9 @@ | ||
from django.db import models | ||
|
||
from location_field.models.plain import PlainLocationField | ||
from location_field.models.spatial import LocationField | ||
|
||
|
||
class Place(models.Model): | ||
parent_place = models.ForeignKey('self', blank=True, null=True) | ||
city = models.CharField(max_length=255) | ||
location = PlainLocationField(based_fields=['city'], zoom=7) | ||
|
||
|
||
class SpatialPlace(models.Model): | ||
parent_place = models.ForeignKey('self', blank=True, null=True) | ||
city = models.CharField(max_length=255) | ||
location = LocationField(based_fields=['city'], zoom=7) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from django.db import models | ||
|
||
from location_field.models.spatial import LocationField | ||
|
||
|
||
class SpatialPlace(models.Model): | ||
parent_place = models.ForeignKey('self', blank=True, null=True) | ||
city = models.CharField(max_length=255) | ||
location = LocationField(based_fields=['city'], zoom=7) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from django.test import TestCase | ||
from django.contrib.gis.geos import Point | ||
|
||
from tests.spatial_models import SpatialPlace | ||
|
||
|
||
class LocationFieldSpatialTest(TestCase): | ||
def test_spatial(self): | ||
vals = { | ||
'city': 'Bauru', | ||
'location': 'POINT(-22.2878573 -49.0905487)', | ||
} | ||
|
||
obj = SpatialPlace.objects.create(**vals) | ||
|
||
self.assertEqual(obj.city, 'Bauru') | ||
self.assertEqual(obj.location, Point(-22.2878573, -49.0905487)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters