Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Adding support for South migrations and changing length of `Country.n…

…ame` and `Territory.name` fields from 32 characters to 64, to accommodate all the values in initial_data.json.
  • Loading branch information...
commit 89fa739d94eceb35a8d7b29a2a21a57eeeaf000a 1 parent 3e56edb
authored March 01, 2012
18  README.mkd
Source Rendered
@@ -22,3 +22,21 @@ Eventually, this Django module will include nice little helpers like template ta
22 22
 There are some nice views included for getting values in serialized form, as well as some nifty form fields and widgets. Some url patterns are supplied to demonstrate serialization using the views. 
23 23
 
24 24
 It's ridiculously simple, yet somehow doesn't exist in the Django-sphere. Please report all bugs to the Git Issue-Tracker, and enjoy the library :)
  25
+
  26
+##South Support##
  27
+
  28
+Support for [South](http://south.aeracode.org/) has been added. If you have previously installed `django-locality` and ran `syncdb`, you will need to run the following commands:
  29
+
  30
+    python manage.py migrate locality 0001 --fake
  31
+    python manage.py migrate locality
  32
+    
  33
+The first migration must be ran with `--fake` since it will attempt to create the tables `django-locality` uses. The second command will run any additional migrations.
  34
+
  35
+If you have *not* previously used `django-locality` you should run the following commands:
  36
+
  37
+    python manage.py syncdb
  38
+    python manage.py migrate locality
  39
+    
  40
+Or, simply:
  41
+
  42
+    python manage.py syncdb --migrate
6  setup.py
@@ -2,12 +2,14 @@
2 2
 
3 3
 setup(
4 4
 	name = "django-locality",
5  
-	version = "0.2.0",
6  
-	url = 'https://github.com/rfkrocktk/django-locality',
  5
+	version = "0.2.0-0.0.1",
  6
+	url = 'https://github.com/chrisdpratt/django-locality',
7 7
 	license = 'AGPL',
8 8
 	description = 'Countries and territories, made usable.',
9 9
 	author = 'TK Kocheran',
10 10
 	author_email = 'rfkrocktk@gmail.com',
  11
+	maintainer = 'Chris Pratt',
  12
+	maintainer_email = 'chrisdpratt@gmail.com',
11 13
 	packages = find_packages('src'),
12 14
 	package_dir = {'': 'src'},
13 15
 	package_data = {
8  src/django_locality.egg-info/PKG-INFO
... ...
@@ -1,10 +1,10 @@
1 1
 Metadata-Version: 1.0
2 2
 Name: django-locality
3  
-Version: 0.1.2
  3
+Version: 0.2.0-0.0.1
4 4
 Summary: Countries and territories, made usable.
5  
-Home-page: https://github.com/rfkrocktk/django-locality
6  
-Author: TK Kocheran
7  
-Author-email: rfkrocktk@gmail.com
  5
+Home-page: https://github.com/chrisdpratt/django-locality
  6
+Author: Chris Pratt
  7
+Author-email: chrisdpratt@gmail.com
8 8
 License: AGPL
9 9
 Description: UNKNOWN
10 10
 Platform: UNKNOWN
6  src/django_locality.egg-info/SOURCES.txt
... ...
@@ -1,5 +1,6 @@
1 1
 MANIFEST.in
2 2
 setup.py
  3
+src/django_locality.egg-info/MANIFEST.in
3 4
 src/django_locality.egg-info/PKG-INFO
4 5
 src/django_locality.egg-info/SOURCES.txt
5 6
 src/django_locality.egg-info/dependency_links.txt
@@ -14,4 +15,7 @@ src/locality/settings.py
14 15
 src/locality/tests.py
15 16
 src/locality/urls.py
16 17
 src/locality/views.py
17  
-src/locality/fixtures/initial_data.json
  18
+src/locality/fixtures/initial_data.json
  19
+src/locality/migrations/0001_initial.py
  20
+src/locality/migrations/0002_auto__chg_field_territory_name__chg_field_country_name.py
  21
+src/locality/migrations/__init__.py
56  src/locality/migrations/0001_initial.py
... ...
@@ -0,0 +1,56 @@
  1
+# encoding: utf-8
  2
+import datetime
  3
+from south.db import db
  4
+from south.v2 import SchemaMigration
  5
+from django.db import models
  6
+
  7
+class Migration(SchemaMigration):
  8
+
  9
+    def forwards(self, orm):
  10
+        
  11
+        # Adding model 'Country'
  12
+        db.create_table('locality_country', (
  13
+            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
  14
+            ('iso2', self.gf('django.db.models.fields.CharField')(unique=True, max_length=2)),
  15
+            ('iso3', self.gf('django.db.models.fields.CharField')(unique=True, max_length=3)),
  16
+            ('name', self.gf('django.db.models.fields.CharField')(unique=True, max_length=32)),
  17
+        ))
  18
+        db.send_create_signal('locality', ['Country'])
  19
+
  20
+        # Adding model 'Territory'
  21
+        db.create_table('locality_territory', (
  22
+            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
  23
+            ('abbr', self.gf('django.db.models.fields.CharField')(max_length=5)),
  24
+            ('name', self.gf('django.db.models.fields.CharField')(max_length=32)),
  25
+            ('country', self.gf('django.db.models.fields.related.ForeignKey')(related_name='territories', to=orm['locality.Country'])),
  26
+        ))
  27
+        db.send_create_signal('locality', ['Territory'])
  28
+
  29
+
  30
+    def backwards(self, orm):
  31
+        
  32
+        # Deleting model 'Country'
  33
+        db.delete_table('locality_country')
  34
+
  35
+        # Deleting model 'Territory'
  36
+        db.delete_table('locality_territory')
  37
+
  38
+
  39
+    models = {
  40
+        'locality.country': {
  41
+            'Meta': {'ordering': "('iso2', 'name')", 'object_name': 'Country'},
  42
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
  43
+            'iso2': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '2'}),
  44
+            'iso3': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '3'}),
  45
+            'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '32'})
  46
+        },
  47
+        'locality.territory': {
  48
+            'Meta': {'ordering': "('abbr', 'name')", 'object_name': 'Territory'},
  49
+            'abbr': ('django.db.models.fields.CharField', [], {'max_length': '5'}),
  50
+            'country': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'territories'", 'to': "orm['locality.Country']"}),
  51
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
  52
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '32'})
  53
+        }
  54
+    }
  55
+
  56
+    complete_apps = ['locality']
44  src/locality/migrations/0002_auto__chg_field_territory_name__chg_field_country_name.py
... ...
@@ -0,0 +1,44 @@
  1
+# encoding: utf-8
  2
+import datetime
  3
+from south.db import db
  4
+from south.v2 import SchemaMigration
  5
+from django.db import models
  6
+
  7
+class Migration(SchemaMigration):
  8
+
  9
+    def forwards(self, orm):
  10
+        
  11
+        # Changing field 'Territory.name'
  12
+        db.alter_column('locality_territory', 'name', self.gf('django.db.models.fields.CharField')(max_length=64))
  13
+
  14
+        # Changing field 'Country.name'
  15
+        db.alter_column('locality_country', 'name', self.gf('django.db.models.fields.CharField')(unique=True, max_length=64))
  16
+
  17
+
  18
+    def backwards(self, orm):
  19
+        
  20
+        # Changing field 'Territory.name'
  21
+        db.alter_column('locality_territory', 'name', self.gf('django.db.models.fields.CharField')(max_length=32))
  22
+
  23
+        # Changing field 'Country.name'
  24
+        db.alter_column('locality_country', 'name', self.gf('django.db.models.fields.CharField')(max_length=32, unique=True))
  25
+
  26
+
  27
+    models = {
  28
+        'locality.country': {
  29
+            'Meta': {'ordering': "('iso2', 'name')", 'object_name': 'Country'},
  30
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
  31
+            'iso2': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '2'}),
  32
+            'iso3': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '3'}),
  33
+            'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '64'})
  34
+        },
  35
+        'locality.territory': {
  36
+            'Meta': {'ordering': "('abbr', 'name')", 'object_name': 'Territory'},
  37
+            'abbr': ('django.db.models.fields.CharField', [], {'max_length': '5'}),
  38
+            'country': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'territories'", 'to': "orm['locality.Country']"}),
  39
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
  40
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '64'})
  41
+        }
  42
+    }
  43
+
  44
+    complete_apps = ['locality']
0  src/locality/migrations/__init__.py
No changes.
4  src/locality/models.py
@@ -7,7 +7,7 @@
7 7
 class Country(models.Model):
8 8
 	iso2 = models.CharField('ISO 3166-1 Alpha 2 Name', max_length=2, unique=True)
9 9
 	iso3 = models.CharField('ISO 3166-1 Alpha 3 Name', max_length=3, unique=True)
10  
-	name = models.CharField('Country Name', max_length=32, unique=True)
  10
+	name = models.CharField('Country Name', max_length=64, unique=True)
11 11
 	
12 12
 	objects = managers.CountryManager()
13 13
 
@@ -32,7 +32,7 @@ class CountryAdmin(admin.ModelAdmin):
32 32
 
33 33
 class Territory(models.Model):
34 34
 	abbr = models.CharField('Territory Abbreviation', max_length=5)
35  
-	name = models.CharField('Territory Name', max_length=32)
  35
+	name = models.CharField('Territory Name', max_length=64)
36 36
 	country = models.ForeignKey('Country', related_name="territories", on_delete=models.CASCADE)
37 37
 	
38 38
 	objects = managers.TerritoryManager()

0 notes on commit 89fa739

Please sign in to comment.
Something went wrong with that request. Please try again.