Skip to content

Commit

Permalink
Fixed bug with south migration additions, added demo models
Browse files Browse the repository at this point in the history
  • Loading branch information
jkatz committed Sep 14, 2011
1 parent ad15c5e commit 09da3de
Show file tree
Hide file tree
Showing 9 changed files with 116 additions and 5 deletions.
Empty file added demo/__init__.py
Empty file.
7 changes: 7 additions & 0 deletions demo/admin.py
@@ -0,0 +1,7 @@
from django.contrib import admin

from models import *

admin.site.register(Map)
admin.site.register(Lotto)
admin.site.register(Subscription)
71 changes: 71 additions & 0 deletions demo/migrations/0001_initial.py
@@ -0,0 +1,71 @@
# encoding: utf-8
import datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models

class Migration(SchemaMigration):

def forwards(self, orm):

# Adding model 'Map'
db.create_table('demo_map', (
('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
('name', self.gf('django.db.models.fields.CharField')(max_length=255)),
('geocode', self.gf('ext.models.PointField')()),
))
db.send_create_signal('demo', ['Map'])

# Adding model 'Lotto'
db.create_table('demo_lotto', (
('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
('name', self.gf('django.db.models.fields.CharField')(max_length=255)),
('numbers', self.gf('ext.models.IntegerArrayField')(null=True, blank=True)),
))
db.send_create_signal('demo', ['Lotto'])

# Adding model 'Subscription'
db.create_table('demo_subscription', (
('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
('name', self.gf('django.db.models.fields.CharField')(max_length=255)),
('period', self.gf('ext.models.DayIntervalField')()),
('price', self.gf('ext.models.MoneyField')(null=True, blank=True)),
))
db.send_create_signal('demo', ['Subscription'])


def backwards(self, orm):

# Deleting model 'Map'
db.delete_table('demo_map')

# Deleting model 'Lotto'
db.delete_table('demo_lotto')

# Deleting model 'Subscription'
db.delete_table('demo_subscription')


models = {
'demo.lotto': {
'Meta': {'object_name': 'Lotto'},
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
'numbers': ('ext.models.IntegerArrayField', [], {'null': 'True', 'blank': 'True'})
},
'demo.map': {
'Meta': {'object_name': 'Map'},
'geocode': ('ext.models.PointField', [], {}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '255'})
},
'demo.subscription': {
'Meta': {'object_name': 'Subscription'},
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
'period': ('ext.models.DayIntervalField', [], {}),
'price': ('ext.models.MoneyField', [], {'null': 'True', 'blank': 'True'})
}
}

complete_apps = ['demo']
Empty file added demo/migrations/__init__.py
Empty file.
15 changes: 15 additions & 0 deletions demo/models.py
@@ -0,0 +1,15 @@
from django.db import models
from ext.models import DayIntervalField, EnumField, IntegerArrayField, MoneyField, PointField

class Map(models.Model):
name = models.CharField(max_length=255)
geocode = PointField()

class Lotto(models.Model):
name = models.CharField(max_length=255)
numbers = IntegerArrayField(blank=True, null=True)

class Subscription(models.Model):
name = models.CharField(max_length=255)
period = DayIntervalField()
price = MoneyField(blank=True, null=True)
16 changes: 16 additions & 0 deletions demo/tests.py
@@ -0,0 +1,16 @@
"""
This file demonstrates writing tests using the unittest module. These will pass
when you run "manage.py test".
Replace this with more appropriate tests for your application.
"""

from django.test import TestCase


class SimpleTest(TestCase):
def test_basic_addition(self):
"""
Tests that 1 + 1 always equals 2.
"""
self.assertEqual(1 + 1, 2)
1 change: 1 addition & 0 deletions demo/views.py
@@ -0,0 +1 @@
# Create your views here.
10 changes: 5 additions & 5 deletions ext/models.py
Expand Up @@ -121,8 +121,8 @@ def __init__(self, *args, **kwargs):
def db_type(self, connection):
return 'point'

add_introspection_rules([], ["^ext\.DayIntervalField"])
add_introspection_rules([], ["^ext\.EnumField"])
add_introspection_rules([], ["^ext\.IntegerArrayField"])
add_introspection_rules([], ["^ext\.MoneyField"])
add_introspection_rules([], ["^ext\.PointField"])
add_introspection_rules([], ["^ext\.models\.DayIntervalField"])
add_introspection_rules([], ["^ext\.models\.EnumField"])
add_introspection_rules([], ["^ext\.models\.IntegerArrayField"])
add_introspection_rules([], ["^ext\.models\.MoneyField"])
add_introspection_rules([], ["^ext\.models\.PointField"])
1 change: 1 addition & 0 deletions settings.py
Expand Up @@ -122,6 +122,7 @@
'django.contrib.admin',
'django.contrib.admindocs',
'ext',
'demo',
'south', # handles migrations
)

Expand Down

0 comments on commit 09da3de

Please sign in to comment.