forked from django-haystack/django-haystack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.py
More file actions
32 lines (26 loc) · 1004 Bytes
/
models.py
File metadata and controls
32 lines (26 loc) · 1004 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# encoding: utf-8
import datetime
from django.db import models
class Checkin(models.Model):
username = models.CharField(max_length=255)
# We're going to do some non-GeoDjango action, since the setup is
# complex enough. You could just as easily do:
#
# location = models.PointField()
#
# ...and your ``search_indexes.py`` could be less complex.
latitude = models.FloatField()
longitude = models.FloatField()
comment = models.CharField(
max_length=140, blank=True, default="", help_text="Say something pithy."
)
created = models.DateTimeField(default=datetime.datetime.now)
class Meta:
ordering = ["-created"]
# Again, with GeoDjango, this would be unnecessary.
def get_location(self):
# Nothing special about this Point, but ensure that's we don't have to worry
# about import paths.
from django.contrib.gis.geos import Point
pnt = Point(self.longitude, self.latitude)
return pnt