Project

General

Profile

Statistics
| Branch: | Revision:

root / env / lib / python2.7 / site-packages / south / introspection_plugins / geodjango.py @ d1a4905f

History | View | Annotate | Download (1.26 KB)

1
"""
2
GeoDjango introspection rules
3
"""
4

    
5
import django
6
from django.conf import settings
7

    
8
from south.modelsinspector import add_introspection_rules
9

    
10
has_gis = "django.contrib.gis" in settings.INSTALLED_APPS
11

    
12
if has_gis:
13
    # Alright,import the field
14
    from django.contrib.gis.db.models.fields import GeometryField
15
    
16
    # Make some introspection rules
17
    if django.VERSION[0] == 1 and django.VERSION[1] >= 1:
18
        # Django 1.1's gis module renamed these.
19
        rules = [
20
            (
21
                (GeometryField, ),
22
                [],
23
                {
24
                    "srid": ["srid", {"default": 4326}],
25
                    "spatial_index": ["spatial_index", {"default": True}],
26
                    "dim": ["dim", {"default": 2}],
27
                    "geography": ["geography", {"default": False}],
28
                },
29
            ),
30
        ]
31
    else:
32
        rules = [
33
            (
34
                (GeometryField, ),
35
                [],
36
                {
37
                    "srid": ["_srid", {"default": 4326}],
38
                    "spatial_index": ["_index", {"default": True}],
39
                    "dim": ["_dim", {"default": 2}],
40
                },
41
            ),
42
        ]
43
    
44
    # Install them
45
    add_introspection_rules(rules, ["^django\.contrib\.gis"])