app/django/contrib/gis/tests/geoapp/models.py
author Madhusudan.C.S <madhusudancs@gmail.com>
Sat, 22 Aug 2009 03:56:04 +0530
changeset 2782 3944749338d3
parent 323 ff1a9aa48cfd
permissions -rw-r--r--
Dotted path to the views in URL patterns is changed to a params parameter. This change makes the URL mapping from URL to View method in patterns generic where the base package path is taken from the params['module_package'] value to support module system of Melange where inherited View classes override the params['module_package'] value to specify their own View methods.

from django.contrib.gis.db import models
from django.contrib.gis.tests.utils import mysql

# MySQL spatial indices can't handle NULL geometries.
null_flag = not mysql

class Country(models.Model):
    name = models.CharField(max_length=30)
    mpoly = models.MultiPolygonField() # SRID, by default, is 4326
    objects = models.GeoManager()
    def __unicode__(self): return self.name

class City(models.Model):
    name = models.CharField(max_length=30)
    point = models.PointField() 
    objects = models.GeoManager()
    def __unicode__(self): return self.name

class State(models.Model):
    name = models.CharField(max_length=30)
    poly = models.PolygonField(null=null_flag) # Allowing NULL geometries here.
    objects = models.GeoManager()
    def __unicode__(self): return self.name

class Feature(models.Model):
    name = models.CharField(max_length=20)
    geom = models.GeometryField()
    objects = models.GeoManager()
    def __unicode__(self): return self.name

class MinusOneSRID(models.Model):
    geom = models.PointField(srid=-1) # Minus one SRID.
    objects = models.GeoManager()