This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def forwards(self, orm): | |
"Write your forwards methods here." | |
def set_real_type(obj): | |
obj.real_type = orm["contenttypes.ContentType"].objects.get_for_model(type(obj)) | |
obj.save() | |
# migrate existing objects | |
for obj in orm.Book.objects.all(): | |
set_real_type(obj) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import models | |
from django.utils.translation import ugettext_lazy as _ | |
from django.core.validators import RegexValidator | |
from django.template.defaultfilters import slugify | |
from django_countries.fields import CountryField | |
from model_utils import Choices | |
from filebrowser.fields import FileBrowseField | |
try: | |
from south.modelsinspector import add_introspection_rules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Migration(SchemaMigration): | |
def forwards(self, orm): | |
# Adding field 'Publication.subclass' | |
db.add_column('publishing_publication', 'subclass', self.gf('django.db.models.fields.CharField')(default='Publication', max_length=48), keep_default=False) | |
for obj in orm.Publication.objects.all(): | |
obj.subclass = '{0}.{1}'.format( | |
obj._meta.app_label, obj.__class__.__name__) | |
obj.save() |
NewerOlder