but this does not:
{{{
class Meta:
indexes = [ models.Index(fields=['a', 'id']) ]
}}}
{{{
File "d/models.py", line 589, in <module>
class Z(models.Model):
File "django/lib/python3.5/site-packages/django/db/models/base.py", line
314, in __new__
index.set_name_with_model(new_class)
File "django/lib/python3.5/site-packages/django/db/models/indexes.py",
line 105, in set_name_with_model
column_names = [model._meta.get_field(field_name).column for
field_name, order in self.fields_orders]
File "django/lib/python3.5/site-packages/django/db/models/indexes.py",
line 105, in <listcomp>
column_names = [model._meta.get_field(field_name).column for
field_name, order in self.fields_orders]
File "django/lib/python3.5/site-packages/django/db/models/options.py",
line 611, in get_field
"be available yet." % (self.object_name, field_name)
django.core.exceptions.FieldDoesNotExist: Z has no field named 'id'. The
app cache isn't ready yet, so if this is an auto-created related field, it
won't be available yet.
}}}
Using 'pk' instead does not help.
Providing, that "The newer indexes option provides more functionality than
index_together. index_together may be deprecated in the future", how shall
I deal with indexes= including the 'id' ?
--
Ticket URL: <https://code.djangoproject.com/ticket/28597>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* status: new => assigned
* owner: nobody => felixxm
* severity: Normal => Release blocker
* stage: Unreviewed => Accepted
--
Ticket URL: <https://code.djangoproject.com/ticket/28597#comment:1>
* has_patch: 0 => 1
Comment:
[https://github.com/django/django/pull/9096 PR]
--
Ticket URL: <https://code.djangoproject.com/ticket/28597#comment:2>
--
Ticket URL: <https://code.djangoproject.com/ticket/28597#comment:3>
* component: Uncategorized => Database layer (models, ORM)
--
Ticket URL: <https://code.djangoproject.com/ticket/28597#comment:4>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"fb02ebe889eee292144f9157ed4ddcdcc139eba9" fb02ebe]:
{{{
#!CommitTicketReference repository=""
revision="fb02ebe889eee292144f9157ed4ddcdcc139eba9"
Fixed #28597 -- Fixed crash with the name of a model's autogenerated
primary key in an Index's fields.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/28597#comment:5>
* cc: Phil Krylov (added)
Comment:
Can someone backport this to 1.11, please?
--
Ticket URL: <https://code.djangoproject.com/ticket/28597#comment:6>
Comment (by Simon Charette):
This won't be backported to 1.11 per our
[https://docs.djangoproject.com/en/2.1/internals/release-process/ backport
policy].
--
Ticket URL: <https://code.djangoproject.com/ticket/28597#comment:7>
Comment (by Дилян Палаузов):
The correction is included in Django 1.11.6, see the release notes.
--
Ticket URL: <https://code.djangoproject.com/ticket/28597#comment:8>
Comment (by Simon Charette):
Hmm it's weird that the backport wasn't reported back here like the commit
against master was.
Here it is for reference cee07ba0880e9d1396795e4823a7371da90cc5cc
--
Ticket URL: <https://code.djangoproject.com/ticket/28597#comment:9>
Comment (by Phil Krylov):
Thanks! For some reason I am still getting this error on 1.11.9. I'll
recheck.
--
Ticket URL: <https://code.djangoproject.com/ticket/28597#comment:10>