标签: django-south

在现有数据库上安装South的问题.MySql不支持'模式更改语句'

我有一个带有现有数据库的django项目,我真的想避免转储或中断.我正在尝试安装South但是当我运行初始迁移时python manage.py migrate example出现以下错误:

Running migrations for example:
- Migrating forwards to 0001_initial.
> example:0001_initial
! Error found during real run of migration! Aborting.

! Since you have a database that does not support running
! schema-altering statements in transactions, we have had 
! to leave it in an interim state between migrations.

! You *might* be able to recover with:   = DROP TABLE `example_page` CASCADE; []
= DROP TABLE `example_likebydate` CASCADE; []
= DROP TABLE `example_followbydate` CASCADE; …
Run Code Online (Sandbox Code Playgroud)

mysql django django-south

4
推荐指数
1
解决办法
2050
查看次数

将Django数据库后端从MySql更改为PostgreSQL

我使用Django 1.2和1.3以及MySql后端.

在使用South迁移MySql数据库时收到错误消息时:

! Error found during real run of migration! Aborting.

! Since you have a database that does not support running
! schema-altering statements in transactions, we have had 
! to leave it in an interim state between migrations.
...
! The South developers regret this has happened, and would
! like to gently persuade you to consider a slightly
! easier-to-deal-with DBMS
Run Code Online (Sandbox Code Playgroud)

我想知道是否将我的数据库从MySql迁移到PostgreSQL可能会阻止此错误.其次,从MySql迁移到PostgreSQL会更多地涉及到在MySql dbase上执行dumpdata,将设置更改为指向PostgreSQL和新后端的loaddata?

我看到了这个 stackoverflow问题,但它谈到他的数据库太大了.我不认为我的数据库会出现这种情况.我的Django项目中没有任何自定义SQL命令.

mysql django postgresql database-migration django-south

4
推荐指数
1
解决办法
2265
查看次数

如何正确加载Django南迁移中的灯具?

我正在使用Django 1.5b1和南部迁移,生活一般都很棒.我有一些架构更新,用于创建我的数据库,其中包括User表.然后ff.User我为(我的自定义用户模型)加载一个fixture :

def forwards(self, orm):
        from django.core.management import call_command
        fixture_path = "/absolute/path/to/my/fixture/load_initial_users.json"
        call_command("loaddata", fixture_path)
Run Code Online (Sandbox Code Playgroud)

一直都很好,直到我在我的ff.User模型中添加了另一个字段,远离迁移线.我的夹具负载现在中断:

DatabaseError: Problem installing fixture 'C:\<redacted>create_users.json':
Could not load ff.User(pk=1): (1054, "Unknown column 'timezone_id' in 'field list'")
Run Code Online (Sandbox Code Playgroud)

Timezone是我添加到用户模型的字段(ForeignKey).

ff.User与数据库中的不同,因此Django ORM放弃了DB错误.不幸的是,我不能在我的夹具中指定我的模型orm['ff.User'],这似乎是南方的做事方式.

我应该如何使用南方正确加载灯具,以便一旦这些灯具的模型被修改后它们不会断开?

django django-south

4
推荐指数
1
解决办法
3783
查看次数

Django South - 创建非空的ForeignKey

我有一个模特

class Mystery(models.Model):
    first = models.CharField(max_length=256)
    second = models.CharField(max_length=256)
    third = models.CharField(max_length=256)
    player = models.ForeignKey(Player)
Run Code Online (Sandbox Code Playgroud)

我添加了播放器ForeignKey但是当我尝试使用South迁移它时,我似乎无法创建这个whith一个null = False.我有这样的信息:

字段'Mystery.player'没有指定默认值,但是NOT NULL.由于您要添加此字段,因此必须指定用于现有行的默认值.是否要:
1.立即退出,并在models.py中的字段中添加默认值
2.指定现在用于现有列的一次性值

我用这个命令:

manage.py schemamigration myapp --auto

非常感谢 !

django django-models django-south

4
推荐指数
2
解决办法
4872
查看次数

南方是否处理模型混合?

我创建了一个mixin并在某些模型中继承了它.问题是当我创建模式迁移时,mixin的字段就在那里.

class MyMixin(object):
    a_field = models.CharField(max_length=30, blank=True)
    another_field = models.DateTimeField(blank=True, null=True)

    class Meta:
        abstract = True


class MyModel(models.Model, myMixin):
    ...
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?

django mixins django-south

4
推荐指数
1
解决办法
554
查看次数

Django灯具.加载初始数据流程正在被杀死

我一直致力于将两个遗留数据库中的57k +记录精炼和重构为一个与Django兼容的实体.现在,当我完成后,我将其作为夹具倾倒,我试图在生产环境中加载它.

我的问题是这个过程在一段时间后被"杀死".我的过程是:

./manage.py syncdb --noinput
./manage.py loaddata core/fixtures/auth.json  # just a default user
./manage.py migrate
Run Code Online (Sandbox Code Playgroud)

结果:

Running migrations for django_extensions:  # custom apps migrate just fine
 - Migrating forwards to 0001_empty.
 > django_extensions:0001_empty
 - Loading initial data for django_extensions.
Installed 0 object(s) from 0 fixture(s)
Running migrations for myotherapp:
 - Migrating forwards to 0001_initial.
 > myotherapp:0001_initial
 - Loading initial data for myotherapp.
Installed 4 object(s) from 1 fixture(s)  # my other app with a fixture migrates ok
Running migrations …
Run Code Online (Sandbox Code Playgroud)

django django-south django-fixtures

4
推荐指数
1
解决办法
2400
查看次数

Django没有为模型创建数据库表(既不使用syncdb也不使用南部)

我在Centos VPS上有一个Django项目.

我创建了一些模型并调试它们,以便它们验证并且不会出错.我将它们放在myapp的"models"文件夹中,并将每个模型添加到此目录中的init文件中,例如:

来自类别进口类别

我将应用程序添加到settings.py INSTALLED_APPS并运行:

Python manage.py syncdb
Run Code Online (Sandbox Code Playgroud)

它似乎工作正常,并添加了除我的应用程序之外的所有表.

然后我安装了South并将其添加到INSTALLED_APPS并再次尝试了syncdb并运行:

Python manage.py schemamigration myapp --initial
Run Code Online (Sandbox Code Playgroud)

它正确生成了文件,但没有任何内容(我的模型没有一个表).

"models"文件夹中的示例文件(usertype.py)

from django.db import models

class UserType(models.Model):
    usertype_id = models.PositiveIntegerField(primary_key=True)
    description = models.CharField(max_length=100)
    is_admin = models.BooleanField()
    is_moderator = models.BooleanField()

class Meta:
    app_label = 'myapp'
Run Code Online (Sandbox Code Playgroud)

任何想法在这里可能会出错,为什么我无法检测到我的模型?

python django syncdb django-south

4
推荐指数
2
解决办法
1万
查看次数

南迁移错误,InnoDB:ROW_FORMAT = DYNAMIC需要innodb_file_format>羚羊

我迁移数据发生错误.
我试着在下面运行原始的SQL:
ALTER TABLE wxwall_participationADD COLUMN eventINT DEFAULT 0
ALTER TABLE wxwall_sceneADD COLUMN welcome_msgVARCHAR(400)NULL
它们工作得非常好,这让我很迷惑.我怎么能解决这个问题?

错误细节:

 - Migrating forwards to 0002_auto__add_field_participation_event__add_field_scene_welcome_msg.
 > wxwall:0002_auto__add_field_participation_event__add_field_scene_welcome_msg
 ! Error found during real run of migration! Aborting.

 ! Since you have a database that does not support running
 ! schema-altering statements in transactions, we have had
 ! to leave it in an interim state between migrations.

! You *might* be able to recover with:   - no dry run output for delete_foreign_key() …
Run Code Online (Sandbox Code Playgroud)

mysql django innodb django-south

4
推荐指数
1
解决办法
3574
查看次数

独立Django app中的迁移

如何在独立的Django应用程序上进行移动(即,如果有任何项目则不属于该应用程序).

例如,以下内容:https://docs.djangoproject.com/en/1.8/intro/reusable-apps/

django django-models django-orm django-south

4
推荐指数
2
解决办法
584
查看次数

通过数据迁移添加默认标签

我正在使用与taggittreebeard一起使用的分层标签.我正在尝试进行数据迁移,因此我可以定义这样的标记,这些标记将出现在应用程序的所有实例中.

我定义了这个方法:

def define_tags(apps, schema_editor):
    HierarchicalTag = apps.get_model("aion", "HierarchicalTag")
    root = HierarchicalTag.add_root(name='root')
    root.save()
    leaf = HierarchicalTag.objects.get(pk=root.pk).add_child(name='ook')
    leaf.save()
Run Code Online (Sandbox Code Playgroud)

应该创建两个标签"root"和一个子"ook".但是,当我运行迁移时,我收到此错误:

AttributeError: type object 'HierarchicalTag' has no attribute 'add_root'
Run Code Online (Sandbox Code Playgroud)

该方法add_rootMP_Node来自treebeard的类方法.

我怎样才能解决这个问题?

django django-treebeard django-south

4
推荐指数
1
解决办法
257
查看次数