我使用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命令.
我在django中构建了一个应用程序,但是因为我发现谷歌应用程序引擎不支持Django开箱即用(免费,云sql不能免费使用吗?).
我决定转移到Django-nonrel,因此很少有datebase字段需要转换,我不知道如何:
class Cate(models.Model):
name = models.CharField(max_length = 100)
description = models.TextField()
create_by = models.ForeignKey(User)
create_date = models.DateTimeField('cate created date')
def __unicode__(self):
return self.name
class Product(models.Model):
product_name = models.CharField(max_length = 200)
owner = models.ForeignKey(User)
cate = models.ManyToManyField(Cate)
timestamp = models.DateTimeField('product added date')
view = models.IntegerField(default = 0)
def __unicode__(self):
return self.product_name
Run Code Online (Sandbox Code Playgroud)
这是user_profile模型,它从用户模型扩展而来
class UserProfile(models.Model):
user = models.OneToOneField(User)
cates = models.ManyToManyField('shop.Cate')
Run Code Online (Sandbox Code Playgroud)
Cate模型由admin创建,UserProfile可以有很多cates,同一个cate可以属于很多用户,与产品相同.
请帮助构建这些模型,并提供一些关于如何使用Django-nonrel的技巧
我是数据库新手