我目前有需要,以應付Django的CMS重寫結構遷移數據的Django南
目前設置如下
class Video(models.Model):
#embed_code_or_url = models.CharField(max_length=2000)
permalink = models.URLField(verify_exists=True, unique=True, max_length=255, default="http://", validators=[validate_youtube_address])
thumbnail = models.CharField(max_length=500, blank=True, null=True)
# Data
title = models.CharField(max_length=255, blank=True)
...
class VideoPlugin(CMSPlugin):
video = models.ForeignKey(Video)
當我現在將我的所有字段從Video
轉移到VideoPlugin
,運行我的schemamigration,我還想在運行遷移時將所有信息從Video轉移到VideoPlugin。
有沒有人有如何實現這個例子?
這裏是移民的beginnig要運行
class Migration(SchemaMigration):
def forwards(self, orm):
# Adding field 'VideoPlugin.permalink'
db.add_column('cmsplugin_videoplugin', 'permalink', self.gf('django.db.models.fields.URLField')(default='http://', unique=True, max_length=255), keep_default=False)
# Adding field 'VideoPlugin.thumbnail'
db.add_column('cmsplugin_videoplugin', 'thumbnail', self.gf('django.db.models.fields.CharField')(max_length=500, null=True, blank=True), keep_default=False)
# Adding field 'VideoPlugin.title'
db.add_column('cmsplugin_videoplugin', 'title', self.gf('django.db.models.fields.CharField')(default='', max_length=255, blank=True), keep_default=False)
...
你的幫助是非常讚賞
可能的重複[如何將模型從一個django應用程序遷移到新的應用程序?](http://stackoverflow.com/questions/1258130/how-do-i-migrate-a-model- django-app-and-into-a-new-one) – dbn