1. 程式人生 > >Power of technology will free your body and spirit

Power of technology will free your body and spirit

問題:
F:\gitserver\oschina\xiaobm\tmpjob\OMS>python manage.py makemigrations
CommandError: Conflicting migrations detected; multiple leaf nodes in the migration graph: (0005_aut
o_20170902_1631, 0003_auto_20170829_1440 in oms).
To fix them run 'python manage.py makemigrations --merge'


>>解決:
刪除migrations目錄下面的自動生成檔案。不要刪除__init__.py


問題2:
有一個表建立不起來,刪除資料庫中全部表格後,重新執行migrate就好了。看來也不那麼可靠啊!
以後才發現,這個問題普通地存在,基本上只要修改了table,重新做python manage.py migrate就會失敗。
只有刪除db,重新建一個空的db才可以成功。成功的代價就是重新建一次表,如果以後有資料記錄怎麼辦呢?
恐怕只有先export出來,再刪除,建空表,匯入!但由於表格變了,匯入可能會有一些問題吧?


測試資料庫開放出來的Api介面:
1.http://127.0.0.1:8000/api/token/add/
方法:POST
body:
{
            "auth_store_id": "668399",
            "app_key": "668399",
            "app_secret": "c10815a09e4eea4538756864280a8009",
            "plat_id": "weidian"
}
輸入:chrome://extensions/。記得,一定要先翻牆才能使用postman
token_create: <QueryDict: {'auth_store_id': ["'668399'"], 'app_key': ['"668399"'], 'app_secret': ["'
c10815a09e4eea4538756864280a8009'"], 'plat_id': ["'weidian'"]}>
[04/Sep/2017 10:29:17] "POST /api/token/add/ HTTP/1.1" 200 122


token_create: <QueryDict: {'auth_store_id': ['668399'], 'app_key': ['668399'], 'app_secret': ['c1081
5a09e4eea4538756864280a8009'], 'plat_id': ['weidian']}>
[04/Sep/2017 10:31:29] "POST /api/token/add/ HTTP/1.1" 200 122


但資料庫並沒有增加記錄。
於是,測試一下plat表,


http://127.0.0.1:8000/api/plat/create/ POST下面的資料:
{
            "name": "youzan"
}

成功增加了三條plat記錄。id是用uuid方法來生成的,並不是自增id。切記,如果手工操作db建立記錄,就會出問題。