how to prevent inserting NULL values and raising exception instead
I commented on your identical issue earlier.

https://github.com/coleifer/peewee/issues/2176#issuecomment-628016499
After running this code, the data will be inserted into the database. when I check the database, I find a row added with values: int_field=0 and other="" (empty string)

My question is how to throw exception in case of Null/empty insert.



import peewee as pw
from datetime import datetime

db = pw.MySQLDatabase('tests', user = 'root', password = 'root', host = 'localhost', port = 3306)


class Model(pw.Model):
    name = pw.CharField()
    created_at = pw.DateTimeField(default = datetime.now())
    other = pw.CharField(null = False)
    int_field = pw.IntegerField(null = False)

    class Meta:
        database = db
        db_table = 'nmodel'

Model.create_table()
Model.create(name = "tests")
