2015-05-04 91 views
1

當我改變了我的模型,並添加了一個datefield遷移不起作用。下面是我添加了什麼:datetime字段沒有遷移django

Birth=models.DateField(editable=False,blank=True) 

,我得到的錯誤是:

match= date_re.match TypeError: expected string or buffer

+0

這是南方遷移,或者Django的=> 1.7遷移? –

+0

django遷移python manage.oy遷移My_App – LazyBrain

+1

完整的追溯?遷移文件本身可能也有幫助。 – knbk

回答

0

按照Django文檔,第一步是使模型的變化,然後運行makemigrations。

例如

$ python manage.py makemigrations 

在運行這段代碼,它會顯示爲

Migrations for 'books': 0003_auto.py: - Alter field author on book

然後: 一旦你有了新的遷移文件,你應該將它們應用到你的數據庫以確保它們按預期工作:

對此,您需要運行

$ python manage.py migrate 

這將是表明

Operations to perform: Synchronize unmigrated apps: sessions, admin, messages, auth, staticfiles, contenttypes Apply all migrations: books Synchronizing apps without migrations: Creating tables...
Installing custom SQL... Installing indexes... Installed 0 object(s) from 0 fixture(s) Running migrations: Applying books.0003_auto... OK

就是這樣。

參考: https://docs.djangoproject.com/en/1.8/topics/migrations/