When doing the basic models on my django app, I have encountered this issue:
The model for a Product stands like this in my app:
main_color = models.CharField(max_length=15)
secondary_color = models.CharField(max_length=15)
brand = models.CharField(max_length=30)
catalog_inclusion_date = models.DateTimeField(default=datetime.now, blank=True)
image_url = models.URLField(max_length=200)
description = models.TextField()
But the catalog_inclusion_date isn't working as intended. After migrating the models to the MySQL database and attempting to insert an entry on the table with this SQL sentence:
INSERT INTO shoppingcart_cap(main_color, secondary_color, catalog_inclusion_date, brand, image_url, description, logo_color)
VALUES ('Red', 'Black', 'Adidas', 'https://www.rekordsport.es/uploads/photo/image/4920/gallery_A02506_1.JPG', 'Kid cap', 'White')
I get the following output:
ERROR 1364 (HY000): Field 'catalog_inclusion_date' doesn't have a default value
Thanks in advance.
Edit: In MySQL, after doing DESCRIBE cap_table;
, I get the following output:
CREATE TABLE `shoppingcart_cap` (
`id` bigint NOT NULL AUTO_INCREMENT,
`main_color` varchar(15) NOT NULL,
`secondary_color` varchar(15) NOT NULL,
`brand` varchar(30) NOT NULL,
`catalog_inclusion_date` date NOT NULL,
`image_url` varchar(200) NOT NULL,
`description` longtext NOT NULL,
`logo_color` varchar(20) NOT NULL,
PRIMARY KEY (`id`)
)