嗨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