On 24/01/2020 3:20 pm, Simon Charette wrote:
If you are using PostgreSQL I'd suggest using a CIText field[0] with a
unique
constraint[1].
Surely everyone uses PostgreSQL, no?
That [0] is identical in Django 2.2 and it looks like I should migrate
my models.CharField to django.contrib.postgresfield.CICharField
I'm already using [1] in Django 2.2
Thank you Simon you have made my day :-)
Cheers
Mike
If you are *not* using PostgreSQL your best choice is likely to
emulate the
upcoming expression[3] support for UniqueConstraint(Lower('field')) by
using
a RunSQL operation that performs the appropriate DDL assuming your backend
supports it.
Best,
Simon
[0]
https://docs.djangoproject.com/en/3.0/ref/contrib/postgres/fields/#citext-fields
[1] https://docs.djangoproject.com/en/3.0/ref/models/fields/#unique
[3] https://github.com/django/django/pull/11929
Le jeudi 23 janvier 2020 21:36:29 UTC-5, Mike Dewhirst a écrit :
What is the best way to ensure a charfield is case-insensitively
unique?
Currently I'm using a query with __iexact=True but I wonder whether
there is a better way.
Thanks
Mike
--
You received this message because you are subscribed to the Google
Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to django-users+unsubscr...@googlegroups.com
<mailto:django-users+unsubscr...@googlegroups.com>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/967c8a27-a8ec-42fc-abf5-bda76fbb5ef9%40googlegroups.com
<https://groups.google.com/d/msgid/django-users/967c8a27-a8ec-42fc-abf5-bda76fbb5ef9%40googlegroups.com?utm_medium=email&utm_source=footer>.
--
You received this message because you are subscribed to the Google Groups "Django
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/afa46f25-214a-0de9-cc20-f58174de2bdf%40dewhirst.com.au.