South allows you to create migrations when you first start out with a new app and the tables haven't been added to the database yet, as well as creating migrations for legacy apps that already have tables in the database. The key is to know when to do what.
Your first mistake was when you deleted your migrations, as soon as you did that, and then ran syncdb, Django didn't know that you wanted south to manage that app anymore, so it created the tables for you. When you created your initial migrations and then ran migrate, south was trying to create tables that django already created, and thus your error.
At this point you have two options.
-
Delete the tables for the wall app from your database and then run
$ py manage.py migrate wall
This will run the migration and create your tables. -
Fake out the initial migration run
$ py manage.py migrate wall 0001 --fake
This will tell south that you already have the tables on the database so just fake it, which will add a row to the south_migrationhistory table, so that the next time you run a migrate it will know that the first migration has already been run.
Here are the steps for setting up south with a brand new project and no database.
- create your database
- add south to installed apps
- run syncdb, this will add the django and south tables to the database
- add your apps
- for each app run
python manage.py schemamigration app_name --initial
this will create the initial migration files for your app - then run south migrate
python manage.py migrate app_name
this will add the tables to the database.
Here are the steps for setting up south with a legacy project and database
- add south to installed apps
- run syncdb, this will add the south tables to the database
- for each of your apps run
python manage.py schemamigration app_name --initial
This will create your initial migrations - for each of your apps run
python manage.py migrate app_name 0001 --fake
, this will fake out south, it won't do anything to the database for those models, it will just add records to the south_migrationhistory table so that the next time you want to create a migration, you are all set.
Here are the steps for setting up south with a legacy project and no database
- create database
- add south to installed apps
- for each of your apps run
python manage.py schemamigration app_name --initial
This will create your initial migrations - run syncdb, this will add any apps that don't have migrations to the database.
- then run south migrate
python manage.py migrate
this will run all migrations for your apps.
Now that you are setup with south, you can start using south to
manage model changes to those apps. The most common command to run is python manage.py schemamigration app_name migration_name --auto
that will look at the last migration you ran and it will find the
changes and build out a migration file for you. Then you just need to
run python manage.py migrate
and it alter your database for you.
Hope that helps.
相关推荐
django-south-admin允许您通过Django的管理界面触发迁移并管理迁移历史。 django-south-admin使用连接到Django的管理界面,并注意用户权限。 内容 安装django-object-tools所描述。 将django-south-admin安装或...
10. **数据库迁移工具(South)**:虽然1.3.1版本的Django还没有内置的迁移系统,但当时的开发者经常使用South这个第三方库来处理数据库模式的变迁。 通过对"Django-1.3.1"源码的深入研究,你可以了解到Django框架...
- 数据迁移:Django的South或内置的makemigrations和migrate命令用于在数据库中创建、更新模型表结构。 3. Django视图(View): - 视图函数:接收HTTP请求并返回HTTP响应,负责业务逻辑的处理。 - 类视图:...
此外,还包括了如何与South一起使用Django CMS,以及如何利用Django CMS进行导航设置等。 3. 高级功能 高级功能部分涉及Django CMS的深入配置和扩展。它包括如下主题: - 国际化:如何使用Django CMS创建支持多语言...
setuptools-1.3.win-amd64-py2.7.exe adodbapi-2.6.0.7.zip Django-1.4.22.tar.gz django-ajax-forms-django-ajax-forms-0.1.1.zip django-ajax-selects-1.4.1.tar.gz django-appconf-1.0.1.tar....South-1.0.2.tar.gz
3. 数据库管理:Django提供了强大的数据库管理工具,如数据库迁移系统(South被集成到Django内核中),用于管理应用程序的数据库结构变化,确保在开发过程中数据的安全。 4. URL路由:Django的URLconfs(URL配置)...
Django 1.6 API 文档详细介绍了以上这些核心概念以及更多细节,包括数据库迁移工具 South 的集成、静态文件处理和部署优化。这个文档是开发者深入理解 Django 1.6 并高效开发 Web 应用的重要资源。通过阅读和学习,...
django-shop-example 一个在 django 1.8 上工作的 django ...pip uninstall south # fix setup.py issues with 3rdparty for django 1.8 python manage.py syncdb --no-initial-data python manage.py syncdb # to loa
Django拥有庞大的生态系统,众多的第三方应用如South(数据库迁移工具)、Django Rest Framework(RESTful API开发)、Sorl.thumbnail(图片处理)等,使得Django可以应对各种复杂的应用场景。 总结,Django作为...
Django 1.3引入了初步的数据库迁移工具South,用于管理模型的版本变化。这使得开发者可以在不破坏现有数据的情况下更新数据库结构。 10. **社区与文档支持** Django有一个活跃的社区,提供了丰富的文档、教程和第...
cookiecutter-django-buildout 带有基于 cookiecutter 的构建模板骨架的 django作者: 亚当·库皮亚乌安装: 安装 cookiecutter ( ) $ pip install cookiecutter 构建模板$ ...engine,默认值:'south','south'、'n
安装与配置: pip install django-menu 将menu添加到您的INSTALLED_APPS ./manage.py migrate menu (如果不使用South, ./manage.py syncdb 。应该使用South。) 将django.template.context_processors.request添加...
同时,它与许多其他Python库和Django应用兼容,如South(数据迁移工具)、dj-database-url(数据库配置解析)等。 **4. 社区和贡献** django-cms 参与了每年的 **Hacktoberfest** 活动,鼓励全球开发者为其开源项目...
django-photomap 这是一个简单的 django 应用程序,它在地图上显示图像并允许用户提交它们。 ... 在您的settings.py makesure包括django.contrib.gis , stdimage , south , tastypie和photomap
Django-PostgresPool 这是一个简单的Postgres连接池后端,适用于Django 1.4+,由漂亮可爱SQLAlchemy提供支持。 用法 使用Django-PostgresPool很简单,只需将django_postgrespool设置为您的连接引擎即可: ...
django-mynewsdesk Django 包安装使用您最喜欢的 Python 安装程序从 PyPI 安装它: pip install django-mynewsdesk快速开始将“mynewsdesk”添加到您的 INSTALLED_APPS 设置中,如下所示: INSTALLED_APPS = ( ......
2. **ORM 和数据库管理** - 提供了对多种数据库的支持,如 SQLite、MySQL、PostgreSQL 和 Oracle,具备数据库迁移工具 South(尽管 1.7 版本后内建了迁移系统)。 3. **表单和验证** - 内置了处理 HTTP 表单的强大...
6. **数据库迁移**:由于"django-groundwork"使用了Django 1.6,所以它可能依赖South进行数据库迁移。South是一种第三方库,用于管理数据库模式的变化。开发者需要创建和应用迁移文件以更新数据库结构,确保数据的...
至于Python库,`djangocms-stackable-plugins`作为Python生态系统的一部分,可能会依赖其他Python库,如Django、Django CMS、South(用于数据库迁移)等。开发者在使用过程中需要注意这些依赖关系,确保所有必要的库...
#django-ueditor-plugin 什么? 该插件是一个 django 后端软件,只需将其添加到您的 django 项目中,然后您就可以使用 ueditor ... for south : python manage.py migrate ueditor for django 1.7+ : python manage.