On 11/24/2015 04:33 AM, Aymeric Augustin wrote:
> 2015-11-23 23:52 GMT+01:00 Carl Meyer <c...@oddbird.net
> <mailto:c...@oddbird.net>>:
> 
>     I've implemented the CITEXT-based solution a couple times; I think for a
>     PostgreSQL-based project it's the preferable option overall.
> 
> Perhaps we should add native support in contrib.postgres?

I'm in favor. I think it's likely as common a need (if not more common)
as the other utilities provided there -- even if most people who need it
are currently probably using an ORM-level or form-level instead of
db-level solution.

> I'm forseeing a small difficulty in terms of API. This is a behavior I'd
> like
> to "mix in" to some fields but I can't say if that will be easy to
> implement.
> 
> The general ideas would be:
> 
> # A mixin
> 
> class CITextField(TextField):
>     # ...
> 
> # Case-insensitive versions of some built-in Django default fields
> # (if we consider that makes sense)
> 
> class CIEmailField(CITextField, EmailField):
>     pass
> 
> # The possibility for users to make custom fields case insensitive
> 
> class CITagField(CITextField, TagField):
>     pass

Here's the entire implementation of my CiEmailField:

    class CiEmailField(models.EmailField):
        """An EmailField that uses the CITEXT Postgres column type."""
        def db_type(self, connection):
            return 'CITEXT'

So I think that's quite amenable to a mixin implementation.

Carl

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/5654BEA9.3080503%40oddbird.net.
For more options, visit https://groups.google.com/d/optout.

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to