Django 1.11 indexes

123 views
Skip to first unread message

Vitaliy Kucherivaiy

unread,
Jan 28, 2017, 4:45:19 PM1/28/17
to Django developers (Contributions to Django itself)
Hi Everyone,

Do I understand this correctly - now there are 2 ways to make a single field indexed in database:
 - FieldClass(db_index=True)
 - Model.Meta.indexes

will it stay like this for future release or 1st approach will be deprecated/removed later ?


Adam Johnson

unread,
Jan 29, 2017, 4:42:06 AM1/29/17
to django-d...@googlegroups.com
Afaik there is no deprecation plan for db_index, and I doubt it would be since it would require lots of projects to update their models for no particular gain. Probably best to think of db_index as a shortcut for adding an index to Meta.indexes.

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/58719258-8ba3-4f9d-9042-b2003786ec2a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Adam

Shai Berger

unread,
Jan 29, 2017, 6:06:35 AM1/29/17
to django-d...@googlegroups.com
On Sunday 29 January 2017 11:41:39 Adam Johnson wrote:
> On 28 January 2017 at 21:45, Vitaliy Kucherivaiy <ppr.v...@gmail.com>
> wrote:
> >
> > Do I understand this correctly - now there are 2 ways to make a single
> > field indexed in database:
> > - FieldClass(db_index=True)
> > - Model.Meta.indexes
> >
> > will it stay like this for future release or 1st approach will be
> > deprecated/removed later ?
> >
> Afaik there is no deprecation plan for *db_index*, and I doubt it would be
> since it would require lots of projects to update their models for no
> particular gain. Probably best to think of *db_index* as a shortcut for
> adding an index to *Meta.indexes*.
>

Exactly. This is similar to the situation with Field(unique=True) vs.
Meta.unique_together.
Reply all
Reply to author
Forward
0 new messages