models.py 596 Bytes
Newer Older
Ben Waters's avatar
Ben Waters committed
1
from django.contrib.gis.db import models
Ben Waters's avatar
Ben Waters committed
2
from rest_framework import serializers
Ben Waters's avatar
Ben Waters committed
3 4 5 6 7

# Create your models here.
class Location(models.Model):
    name = models.CharField(max_length=50)
    area = models.IntegerField()
Ben Waters's avatar
Ben Waters committed
8 9 10 11
    minLon = models.FloatField()
    maxLon = models.FloatField()
    minLat = models.FloatField()
    minLat = models.FloatField()
Ben Waters's avatar
Ben Waters committed
12 13 14

    objects = models.GeoManager()

Ben Waters's avatar
Ben Waters committed
15
    def __unicode__(self):
Ben Waters's avatar
Ben Waters committed
16 17
        return self.name

Ben Waters's avatar
Ben Waters committed
18 19 20
class LocationSerializer(serializers.ModelSerializer):
	class Meta:
		model = Location
Ben Waters's avatar
Ben Waters committed
21
		fields = ('id', 'name', 'area', 'minLon', 'maxLon', 'minLat', 'maxLat')