Warning: Field 'id' doesn't have a default value
|Reported by:||Eduardo Klein||Owned by:||nobody|
|Component:||Database layer (models, ORM)||Version:||1.7-rc-2|
|Severity:||Normal||Keywords:||model default value|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
This is a problem that I don't have with django 1.7.b4, but I do have it with 1.7c2.
I have a model like this:
class Image(models.Model): id = models.AutoField(primary_key=True) datetime = models.DateTimeField(default=datetime.now) file = models.FileField() #some other fields
At some point of my code, I do:
image = Image() ... image.file.save(filename, file_content) image.save()
This works fine with django 1.7.b4, but gives the following error (even if it says warning):
"Field 'id' doesn't have a default value"
My db backend is MySQL.
This seems to be a bug, since I did not find anything in the release notes that says that this was not possible in django 1.7
I have tried to create a test model to reproduce the problem, but all the tests I made with the 3 fields above only passed (no errors). There must be some specific condition in my model that makes it fails.
Since you know what has changed from 1.7.b4 to 1.7c2, do yoy know or have an idea of what maybe happening. If you give me directions on what have changed, I can make more tests to reproduce the bug.
Change History (8)
comment:1 Changed 2 years ago by
|Patch needs improvement:||unset|