In peewee I have a model where I want to strip the white space of some fields when an instance is created. Is it possible to do this?
e.g.
import peewee as pw
class Person(pw.Model):
email = pw.CharField()
name = pw.CharField()
mom = Person(email=" [email protected] ", name=" Stella Bird ") # <- white space should be stripped automatically
To be able to clear out the white space you will need to use
strip()in your class. Start by making an__init__function in your class that takes in positional and keyword arguments.This will strip the white space from the
emailandname.The output with no white space: