Django Column 'id' cannot be null
I am having a weird problem with my mysql database and django.
I created an app with a model imported from an existing database with inspectdb. It was working fine until yesterday I removed the django automatically created tables (django_, auth_, site_*). I did that because it was preventing my model to validate when I added my app in the installed apps.
Now开发者_Go百科 today I tried inserting a new record in my database and I get the following error :
Django Version: 1.3
Exception Type: IntegrityError
Exception Value: (1048, "Column 'asset_id' cannot be null")
The field is a primary key and it's supposed to be auto_increment so I don't give a value to it when I create a new record.
Can someone point me what's going on here ?
EDIT : I partly figured out the problem : somehow all my auto_increment proprities were removed from my database. How did that happen ?
Check your generated models, and ensure that the "auto_increment" columns correspond with fields marked with the primary_key=True
option.
May be you need to save your object model, before obtain id
property.
精彩评论