3๐
You can have another field which is basically the slug of the name. Infact, I believe it is not a good idea to have the name
as a unique field (but i should clarify that i do not know your requirement).
Basically, the validation on the slug field ensures uniqueness. Also, you can just keep the slug field hidden from all forms, etc..
Example:
>>> from django.utils.text import slugify
>>> slugify(u"ลtack Overflow")
u'stack-overflow'
>>> slugify(u"stack Overflow")
u'stack-overflow'
>>> slugify(u"stack Overflow")
u'stack-overflow'
>>> slugify(u"stack \t Overflow")
u'stack-overflow'
>>> slugify(u"stack \n Overflow")
u'stack-overflow'
A few of these combinations map to the same slug โ which ensures uniqueness for the broad usecases.
3๐
An idea would be to implement a case insensitive unique constraint on the field.
Possible answers in:
- [Django]-Django Site encryption
- [Django]-Django: How to dynamic filter foreignkey choices by Customizing the Django_Admin
- [Django]-Django: Casting Abstract Models
0๐
Just save both full_name and clean_full_name in the database, and make clean_full_name unique.
You can validate the full_name field by putting the validation code in a property setter. Have a look at this blog for details.
- [Django]-Django: Using DataTables
- [Django]-Django admin upload and image to s3 and then resize the image and save a thumb problem
- [Django]-Asterisk in django forms validation messages