嗨Stackoverflow人,PostgreSQL + Django + South的第一步
在过去,我总是用sqlite作为数据库平台在本地开发我的Django项目。现在,我想转移到PostgreSQL以利用GIS功能,但过渡给了我巨大的悲痛。
我已经安装了类似于这个post的postgresql,然后按照GeoDjango description来创建数据库。
而且,我通过
from django.contrib.gis.db import models
更换机型类,并添加
geolocation = models.PointField(_('Geo Location'),
geography=True,
help_text=_('Geolocation with Longitude and Latitude'))
objects = models.GeoManager()
现在,潜水更深前到PostgreSQL的球,我想测试通过Django管理模型的访问,我遇到了第一个错误。
当我选择的模式在管理(我只是修改为上面提到的),我收到以下错误:
**InternalError at /admin/remap/project/**
current transaction is aborted, commands ignored until end of transaction block
此错误与错误的SQL查询连接,但我很奇怪Django Admin创建了错误的sql语句(由百万开发人员使用,并且在早期的sqlite配置中工作正常)。
当我检查Django的SQL语句,我可以看到的PointField
"geolocation" geography(POINT,4326) NOT NULL,
入门,但是当我检查psql的\ d项目,我看不到改变的PointField(此是什么应该导致错误)。由于我使用的南,我执行
./manage.py schemamigration projects --initial
./manage.py migrate projects
,但我得到的消息
Running migrations for projects:
- Nothing to migrate.
- Loading initial data for projects.
我如何说服南/ PostgreSQL的,有一些迁移? 你是否发现SQLite过渡到PostgreSQL的其他问题?
谢谢您的回答& help!
随着数据库的安装,你应该首先[转换应用程序](http://south.aeracode.org /docs/convertinganapp.html)使用south,对模型进行更改,然后运行['schemamigration'](http://south.aeracode.org/docs/commands.html#schemamigration),以便south创建迁移最后通过['migrate'](http://south.aeracode.org/docs/commands.html#migrate)命令应用该迁移。根据你的问题判断,你改变了模型,然后运行没有任何冻结模型的模式迁移,以比较当前模型,以便它不能检测到任何变化。 – 2012-01-28 13:33:42