[Django]-Django UserProfile slug field

3👍

✅

It means you already have some records in userprofile table with empty/null values in slug field. Because you’ve marked that field as unique=True it can only have one field with empty value. To avoid this error, delete the records with empty value in slug field, or just assign them a unique slug and you’ll be good to go.

And as you can understand from above, having default='' in a field that has unique=True wont work. Unique means unique, even '' as an empty value is considered a unique value and can be used in just one row if you have unique=True. That also means you cannot have any default value in a unique field.

Leave a comment