From f3c54e80398615f51ce2b78155beba907639d48b Mon Sep 17 00:00:00 2001 From: Tom Offermann Date: Wed, 2 Oct 2013 20:57:06 -0700 Subject: [PATCH] Add migration to set site domain and name. --- .../0002_set_site_domain_and_name.py | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 {{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/users/migrations/0002_set_site_domain_and_name.py diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/users/migrations/0002_set_site_domain_and_name.py b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/users/migrations/0002_set_site_domain_and_name.py new file mode 100644 index 00000000..d7843f2a --- /dev/null +++ b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/users/migrations/0002_set_site_domain_and_name.py @@ -0,0 +1,73 @@ +# -*- coding: utf-8 -*- +import datetime +from south.db import db +from south.v2 import DataMigration +from django.conf import settings +from django.db import models + + +class Migration(DataMigration): + + def forwards(self, orm): + """Set site domain and name.""" + Site = orm['sites.Site'] + site = Site.objects.get(id=settings.SITE_ID) + site.domain = "{{cookiecutter.domain_name}}" + site.name = "{{cookiecutter.project_name}}" + site.save() + + def backwards(self, orm): + """Revert site domain and name to default.""" + Site = orm['sites.Site'] + site = Site.objects.get(id=settings.SITE_ID) + site.domain = 'example.com' + site.name = 'example.com' + site.save() + + models = { + u'auth.group': { + 'Meta': {'object_name': 'Group'}, + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}), + 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) + }, + u'auth.permission': { + 'Meta': {'ordering': "(u'content_type__app_label', u'content_type__model', u'codename')", 'unique_together': "((u'content_type', u'codename'),)", 'object_name': 'Permission'}, + 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) + }, + u'contenttypes.contenttype': { + 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, + 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}) + }, + u'sites.site': { + 'Meta': {'ordering': "(u'domain',)", 'object_name': 'Site', 'db_table': "u'django_site'"}, + 'domain': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) + }, + u'users.user': { + 'Meta': {'object_name': 'User'}, + 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), + 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}), + 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), + 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "u'user_set'", 'blank': 'True', 'to': u"orm['auth.Group']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), + 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), + 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}), + 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "u'user_set'", 'blank': 'True', 'to': u"orm['auth.Permission']"}), + 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) + } + } + + complete_apps = ['sites', 'users'] + symmetrical = True