Commits

Matt Bone  committed cc7c935 Draft

adding south support, example models, first migration

  • Participants
  • Parent commits c6c7148

Comments (0)

Files changed (5)

File requirements.txt

 South==0.7.5
 ipython==0.12.1
 Fabric==1.4.2
+psycopg2==2.4.5

File stub_app/migrations/0001_initial.py

+# -*- coding: 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 'Poll'
+        db.create_table('stub_app_poll', (
+            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
+            ('question', self.gf('django.db.models.fields.CharField')(max_length=200)),
+            ('pub_date', self.gf('django.db.models.fields.DateTimeField')()),
+        ))
+        db.send_create_signal('stub_app', ['Poll'])
+
+        # Adding model 'Choice'
+        db.create_table('stub_app_choice', (
+            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
+            ('poll', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['stub_app.Poll'])),
+            ('choice_text', self.gf('django.db.models.fields.CharField')(max_length=200)),
+            ('votes', self.gf('django.db.models.fields.IntegerField')()),
+        ))
+        db.send_create_signal('stub_app', ['Choice'])
+
+
+    def backwards(self, orm):
+        # Deleting model 'Poll'
+        db.delete_table('stub_app_poll')
+
+        # Deleting model 'Choice'
+        db.delete_table('stub_app_choice')
+
+
+    models = {
+        'stub_app.choice': {
+            'Meta': {'object_name': 'Choice'},
+            'choice_text': ('django.db.models.fields.CharField', [], {'max_length': '200'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'poll': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['stub_app.Poll']"}),
+            'votes': ('django.db.models.fields.IntegerField', [], {})
+        },
+        'stub_app.poll': {
+            'Meta': {'object_name': 'Poll'},
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'pub_date': ('django.db.models.fields.DateTimeField', [], {}),
+            'question': ('django.db.models.fields.CharField', [], {'max_length': '200'})
+        }
+    }
+
+    complete_apps = ['stub_app']

File stub_app/migrations/__init__.py

Empty file added.

File stub_app/models.py

 from django.db import models
 
-# Create your models here.
+class Poll(models.Model):
+    question = models.CharField(max_length=200)
+    pub_date = models.DateTimeField('date published')
+
+class Choice(models.Model):
+    poll = models.ForeignKey(Poll)
+    choice_text = models.CharField(max_length=200)
+    votes = models.IntegerField()

File stub_django/settings.py

 
 DATABASES = {
     'default': {
-        'ENGINE': 'django.db.backends.', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
-        'NAME': '',                      # Or path to database file if using sqlite3.
-        'USER': '',                      # Not used with sqlite3.
-        'PASSWORD': '',                  # Not used with sqlite3.
-        'HOST': '',                      # Set to empty string for localhost. Not used with sqlite3.
-        'PORT': '',                      # Set to empty string for default. Not used with sqlite3.
-    }
+        'ENGINE': 'django.db.backends.sqlite3', 
+        'NAME': '/tmp/stub_django.db',
+        'USER': '',
+        'PASSWORD': '',
+        'HOST': '',
+        'PORT': '',
+    },
+    # 'default': {
+    #     'ENGINE': 'django.db.backends.postgresql_psycopg2', 
+    #     'NAME': '',
+    #     'USER': '',
+    #     'PASSWORD': '',
+    #     'HOST': '',
+    #     'PORT': '',
+    # },
 }
 
 # Local time zone for this installation. Choices can be found here:
     # 'django.contrib.admin',
     # Uncomment the next line to enable admin documentation:
     # 'django.contrib.admindocs',
+    'south',
 )
 
 # A sample logging configuration. The only tangible logging