[Fixed]-Unique if not null SQLAlchemy and Django

15👍

Multiple rows with NULL values should not be a problem for the unique constraint. Only “values” must be unique, NULL is no value.

Have you tried?:

upc = Column(String(), unique=True, nullable=True) 

Leave a comment