Permalink
Browse files

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...
cprattmfah committed Mar 1, 2012
1 parent 3e56edb commit 89fa739d94eceb35a8d7b29a2a21a57eeeaf000a
View
@@ -22,3 +22,21 @@ Eventually, this Django module will include nice little helpers like template ta
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.
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 :)
+
+##South Support##
+
+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:
+
+ python manage.py migrate locality 0001 --fake
+ python manage.py migrate locality
+
+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.
+
+If you have *not* previously used `django-locality` you should run the following commands:
+
+ python manage.py syncdb
+ python manage.py migrate locality
+
+Or, simply:
+
+ python manage.py syncdb --migrate
View
@@ -2,12 +2,14 @@
setup(
name = "django-locality",
- version = "0.2.0",
- url = 'https://github.com/rfkrocktk/django-locality',
+ version = "0.2.0-0.0.1",
+ url = 'https://github.com/chrisdpratt/django-locality',
license = 'AGPL',
description = 'Countries and territories, made usable.',
author = 'TK Kocheran',
author_email = 'rfkrocktk@gmail.com',
+ maintainer = 'Chris Pratt',
+ maintainer_email = 'chrisdpratt@gmail.com',
packages = find_packages('src'),
package_dir = {'': 'src'},
package_data = {
@@ -1,10 +1,10 @@
Metadata-Version: 1.0
Name: django-locality
-Version: 0.1.2
+Version: 0.2.0-0.0.1
Summary: Countries and territories, made usable.
-Home-page: https://github.com/rfkrocktk/django-locality
-Author: TK Kocheran
-Author-email: rfkrocktk@gmail.com
+Home-page: https://github.com/chrisdpratt/django-locality
+Author: Chris Pratt
+Author-email: chrisdpratt@gmail.com
License: AGPL
Description: UNKNOWN
Platform: UNKNOWN
@@ -1,5 +1,6 @@
MANIFEST.in
setup.py
+src/django_locality.egg-info/MANIFEST.in
src/django_locality.egg-info/PKG-INFO
src/django_locality.egg-info/SOURCES.txt
src/django_locality.egg-info/dependency_links.txt
@@ -14,4 +15,7 @@ src/locality/settings.py
src/locality/tests.py
src/locality/urls.py
src/locality/views.py
-src/locality/fixtures/initial_data.json
+src/locality/fixtures/initial_data.json
+src/locality/migrations/0001_initial.py
+src/locality/migrations/0002_auto__chg_field_territory_name__chg_field_country_name.py
+src/locality/migrations/__init__.py
@@ -0,0 +1,56 @@
+# 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 'Country'
+ db.create_table('locality_country', (
+ ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
+ ('iso2', self.gf('django.db.models.fields.CharField')(unique=True, max_length=2)),
+ ('iso3', self.gf('django.db.models.fields.CharField')(unique=True, max_length=3)),
+ ('name', self.gf('django.db.models.fields.CharField')(unique=True, max_length=32)),
+ ))
+ db.send_create_signal('locality', ['Country'])
+
+ # Adding model 'Territory'
+ db.create_table('locality_territory', (
+ ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
+ ('abbr', self.gf('django.db.models.fields.CharField')(max_length=5)),
+ ('name', self.gf('django.db.models.fields.CharField')(max_length=32)),
+ ('country', self.gf('django.db.models.fields.related.ForeignKey')(related_name='territories', to=orm['locality.Country'])),
+ ))
+ db.send_create_signal('locality', ['Territory'])
+
+
+ def backwards(self, orm):
+
+ # Deleting model 'Country'
+ db.delete_table('locality_country')
+
+ # Deleting model 'Territory'
+ db.delete_table('locality_territory')
+
+
+ models = {
+ 'locality.country': {
+ 'Meta': {'ordering': "('iso2', 'name')", 'object_name': 'Country'},
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'iso2': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '2'}),
+ 'iso3': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '3'}),
+ 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '32'})
+ },
+ 'locality.territory': {
+ 'Meta': {'ordering': "('abbr', 'name')", 'object_name': 'Territory'},
+ 'abbr': ('django.db.models.fields.CharField', [], {'max_length': '5'}),
+ 'country': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'territories'", 'to': "orm['locality.Country']"}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '32'})
+ }
+ }
+
+ complete_apps = ['locality']
@@ -0,0 +1,44 @@
+# 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):
+
+ # Changing field 'Territory.name'
+ db.alter_column('locality_territory', 'name', self.gf('django.db.models.fields.CharField')(max_length=64))
+
+ # Changing field 'Country.name'
+ db.alter_column('locality_country', 'name', self.gf('django.db.models.fields.CharField')(unique=True, max_length=64))
+
+
+ def backwards(self, orm):
+
+ # Changing field 'Territory.name'
+ db.alter_column('locality_territory', 'name', self.gf('django.db.models.fields.CharField')(max_length=32))
+
+ # Changing field 'Country.name'
+ db.alter_column('locality_country', 'name', self.gf('django.db.models.fields.CharField')(max_length=32, unique=True))
+
+
+ models = {
+ 'locality.country': {
+ 'Meta': {'ordering': "('iso2', 'name')", 'object_name': 'Country'},
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'iso2': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '2'}),
+ 'iso3': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '3'}),
+ 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '64'})
+ },
+ 'locality.territory': {
+ 'Meta': {'ordering': "('abbr', 'name')", 'object_name': 'Territory'},
+ 'abbr': ('django.db.models.fields.CharField', [], {'max_length': '5'}),
+ 'country': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'territories'", 'to': "orm['locality.Country']"}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '64'})
+ }
+ }
+
+ complete_apps = ['locality']
No changes.
View
@@ -7,7 +7,7 @@
class Country(models.Model):
iso2 = models.CharField('ISO 3166-1 Alpha 2 Name', max_length=2, unique=True)
iso3 = models.CharField('ISO 3166-1 Alpha 3 Name', max_length=3, unique=True)
- name = models.CharField('Country Name', max_length=32, unique=True)
+ name = models.CharField('Country Name', max_length=64, unique=True)
objects = managers.CountryManager()
@@ -32,7 +32,7 @@ class CountryAdmin(admin.ModelAdmin):
class Territory(models.Model):
abbr = models.CharField('Territory Abbreviation', max_length=5)
- name = models.CharField('Territory Name', max_length=32)
+ name = models.CharField('Territory Name', max_length=64)
country = models.ForeignKey('Country', related_name="territories", on_delete=models.CASCADE)
objects = managers.TerritoryManager()

0 comments on commit 89fa739

Please sign in to comment.