设为首页 加入收藏

TOP

django:数据库修改工具South的正确使用方式 (一)
2014-11-23 23:37:42 来源: 作者: 【 】 浏览:24
Tags:django 数据库 修改 工具 South 正确 使用 方式

如果你在使用south,然而并没有遇到本文所提到的错误,我则建议你跳到本文的第三部分看一看,我想ken的详尽建议可能对你也会有所帮助。

1 什么是south

由于django 的syncdb只能在数据库创建的时候发挥作用,而对Model进行更改之后再运行syncdb是不能将更改反映到数据库中的。只能就要自己使用其他原始而蹩脚的方式进行修改操作。south就是解决这个问题的工具。

2 遵守south手册带来的错误

你也许按照south手册的要求,进行了以下操作:

1)首先创建了一个数据库

	create database mydb;

2)然后把“south”放在settings.py中的INSTALLED_APPS 然后在console中执行以下命令

	$ python manage.py  schemamigration wall --initial

这步没问题

	$ python manage.py migrate wall

这条命令则报出了以下错误

< SPAN style = "BACKGROUND-COLOR: #c0c0c0" >Skipping creation of NoticeTypes as notification app not found
Running migrations for profiles:
- Migrating forwards to 0002_auto__add_field_interest_created_on__add_field_profile_created_on__add.
> profiles:0001_initial
south execute "CREATE TABLE "profiles_profile" ("id" integer NOT NULL PRIMARY KEY, "user_id" integer NOT NULL UNIQUE, "first_name" varchar(30) NOT NULL, "last_name" varchar(30) NOT NULL, "location" varchar(255) NOT NULL, "image" varchar(100) NOT NULL, "bio" text NOT NULL);" with params "[]"
Traceback (most recent call last):
File "manage.py", line 26, in < module >
execute_manager(settings)
File "/Library/Python/2.6/site-packages/django/core/management/__init__.py", line 438, in execute_manager
utility.execute()
File "/Library/Python/2.6/site-packages/django/core/management/__init__.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Library/Python/2.6/site-packages/django/core/management/base.py", line 191, in run_from_argv
self.execute(*args, **options.__dict__)
File "/Library/Python/2.6/site-packages/django/core/management/base.py", line 220, in execute
output = self.handle(*args, **options)
File "/Library/Python/2.6/site-packages/south/management/commands/migrate.py", line 105, in handle
ignore_ghosts = ignore_ghosts,
File "/Library/Python/2.6/site-packages/south/migration/__init__.py", line 191, in migrate_app
success = migrator.migrate_many(target, workplan, database)
File "/Library/Python/2.6/site-packages/south/migration/migrators.py", line 221, in migrate_many
result = migrator.__class__.migrate_many(migrator, target, migrations, database)
File "/Library/Python/2.6/site-packages/south/migration/migrators.py", line 292, in migrate_many
result = self.migrate(migration, database)
File "/Library/Python/2.6/site-packages/south/migration/migrators.py", line 125, in migrate
result = self.run(migration)
File "/Library/Python/2.6/site-packages/south/migration/migrators.py", line 99, in run
return self.run_migration(migration)
File "/Library/Python/2.6/site-packages/south/migration/migrators.py", line 81, in run_migration
migration_function()
File "/Library/Python/2.6/site-packages/south/migration/migrators.py", line 57, in < lambda >
return (lambda: direction(orm))
File "/Users/neddo/Sites/Mozilla/drumbeat/batucada/apps/profiles/migrations/0001_initial.py", line 19, in forwards
('bio', self.gf('django.db.models.fields.TextField')()),
File "/Library/Python/2.6/site-packages/south/db/gen
首页 上一页 1 2 下一页 尾页 1/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇搭建Hive的图形界面 下一篇排序合并连接(sort merge join)的..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: