#28597: Model.Meta.indexes : model has no field named 'id' -------------------------------------+------------------------------------- Reporter: Дилян | Owner: nobody Палаузов | Type: Bug | Status: new Component: | Version: 1.11 Uncategorized | Severity: Normal | Keywords: Model.Meta.indexes Triage Stage: | Has patch: 0 Unreviewed | Needs documentation: 0 | Needs tests: 0 Patch needs improvement: 0 | Easy pickings: 0 UI/UX: 0 | -------------------------------------+------------------------------------- This works: {{{ class Z(models.Model) a = models.BooleanField() class Meta: index_together = ['a', 'id']` }}}
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. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/057.8791a6b4758150e02c31b4fc823e347e%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.