Re: Adding an Index to a model with a custom Field.

2018-05-26 Thread Jan Pieter Waagmeester
I just discussed with Markus H here at DjangoCon Europe, apparently he did a presentation last year about this, which reflects some of the thoughts from above: https://speakerdeck.com/markush/to-index-or-not-thats-not-the-question-djangocon-europe-2017?slide=35 -- You received this message bec

Re: Adding an Index to a model with a custom Field.

2017-12-08 Thread Jan Pieter Waagmeester
On Wednesday, 6 December 2017 00:45:09 UTC+1, charettes wrote: > > From what I remember this feature was planned to be used to replace ` > BaseSpatialField` > special handling of `spatial_index` and allow custom fields to define > > This lead me to some DEP drafts on indexes here: - https://git

Re: Adding an Index to a model with a custom Field.

2017-12-05 Thread charettes
Hello Jan, I'm a bit surprised the `contribute_to_class` approach isn't working but I remember there was previous discussions to support passing an `Index` instance to the `Field.db_index` option or to allow an `index_class` attribute to be defined on `Field` subclasses to determine what kind o

Re: Adding an Index to a model with a custom Field.

2017-12-05 Thread James Bennett
I can think of several cases where I'd want a custom field to be able to add an index, and contribute_to_class() is, as you say, the natural place to do it -- it's the hook for everything else fields want to add as part of their setup. So I'd be +1 on making sure it's possible to add indexes throu

Adding an Index to a model with a custom Field.

2017-12-05 Thread Jan Pieter Waagmeester
As part of django-modeltrans , I'm trying to add a GinIndex to the model when a custom Field is added. The simplified version of my naive implementation looks like this: from django.contrib.postgres.fields import JSONField from django.contrib.postgre