[Django] #35749: AlterIndexTogether raising TypeError: 'class Meta' got invalid attribute(s): index_together

23 views
Skip to first unread message

Django

unread,
Sep 9, 2024, 11:32:53 PM9/9/24
to django-...@googlegroups.com
#35749: AlterIndexTogether raising TypeError: 'class Meta' got invalid
attribute(s): index_together
-------------------------------------+-------------------------------------
Reporter: dishn | Type: Bug
Status: new | Component:
| Migrations
Version: 5.1 | Severity: Normal
Keywords: AlterIndexTogether, | Triage Stage:
index_together | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
According to the documentation: "The AlterIndexTogether migration
operation is now officially supported only for pre-Django 4.2 migration
files. For backward compatibility reasons, it’s still part of the public
API, and there’s no plan to deprecate or remove it, but it should not be
used for new migrations. Use AddIndex and RemoveIndex operations instead."
But when running make migrate it gave error `TypeError: 'class Meta' got
invalid attribute(s): index_together`. Is this an issue or should am I
misunderstanding the problem?
--
Ticket URL: <https://code.djangoproject.com/ticket/35749>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Sep 10, 2024, 3:32:13 AM9/10/24
to django-...@googlegroups.com
#35749: AlterIndexTogether raising TypeError: 'class Meta' got invalid
attribute(s): index_together
-------------------------------------+-------------------------------------
Reporter: Dishen Wang | Owner: (none)
Type: Bug | Status: closed
Component: Migrations | Version: 5.1
Severity: Normal | Resolution: duplicate
Keywords: AlterIndexTogether, | Triage Stage:
index_together | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce):

* resolution: => duplicate
* status: new => closed

Comment:

Duplicate of #34856, #35679

The [https://docs.djangoproject.com/en/dev/releases/4.2/#index-together-
option-is-deprecated-in-favor-of-indexes 4.2 release notes] say the
following:

> Next, consider squashing migrations to remove index_together from
historical migrations.
--
Ticket URL: <https://code.djangoproject.com/ticket/35749#comment:1>

Django

unread,
Nov 14, 2024, 9:41:16 AM11/14/24
to django-...@googlegroups.com
#35749: AlterIndexTogether raising TypeError: 'class Meta' got invalid
attribute(s): index_together
-------------------------------------+-------------------------------------
Reporter: Dishen Wang | Owner: (none)
Type: Bug | Status: closed
Component: Migrations | Version: 5.1
Severity: Normal | Resolution: duplicate
Keywords: AlterIndexTogether, | Triage Stage:
index_together | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Andrés Reverón Molina):

It seems like the suggested workaround is to squash migrations, but
unfortunately the AlterIndexTogether operation is still included in the
squashed migration, so this does not help.
--
Ticket URL: <https://code.djangoproject.com/ticket/35749#comment:2>

Django

unread,
Nov 14, 2024, 9:45:27 AM11/14/24
to django-...@googlegroups.com
#35749: AlterIndexTogether raising TypeError: 'class Meta' got invalid
attribute(s): index_together
-------------------------------------+-------------------------------------
Reporter: Dishen Wang | Owner: (none)
Type: Bug | Status: closed
Component: Migrations | Version: 5.1
Severity: Normal | Resolution: duplicate
Keywords: AlterIndexTogether, | Triage Stage:
index_together | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Dishen Wang):

That is correct Andrés, The work around for me was to modify the old
migration/squashed files and replace AlterIndexTogether with a pair of
operations RemoveIndex then AddIndex. You can then check for migrations
and make sure the there are no changes after the modifications.
--
Ticket URL: <https://code.djangoproject.com/ticket/35749#comment:3>

Django

unread,
Nov 14, 2024, 12:16:06 PM11/14/24
to django-...@googlegroups.com
#35749: AlterIndexTogether raising TypeError: 'class Meta' got invalid
attribute(s): index_together
-------------------------------------+-------------------------------------
Reporter: Dishen Wang | Owner: (none)
Type: Bug | Status: closed
Component: Migrations | Version: 5.1
Severity: Normal | Resolution: duplicate
Keywords: AlterIndexTogether, | Triage Stage:
index_together | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Andrés Reverón Molina):

Thank you! I will do that.

However it seems to me like this a very valid bug report and it should not
be marked as closed.

I think AlterIndexTogether should either be completely removed, or fixed
so that it does not crash. The current state is quite confusing.
--
Ticket URL: <https://code.djangoproject.com/ticket/35749#comment:4>

Django

unread,
Nov 15, 2024, 5:39:59 AM11/15/24
to django-...@googlegroups.com
#35749: AlterIndexTogether raising TypeError: 'class Meta' got invalid
attribute(s): index_together
-------------------------------------+-------------------------------------
Reporter: Dishen Wang | Owner: (none)
Type: Bug | Status: new
Component: Migrations | Version: 5.1
Severity: Normal | Resolution:
Keywords: AlterIndexTogether, | Triage Stage:
index_together | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Andrés Reverón Molina):

* resolution: duplicate =>
* status: closed => new

--
Ticket URL: <https://code.djangoproject.com/ticket/35749#comment:5>

Django

unread,
Nov 15, 2024, 6:42:51 AM11/15/24
to django-...@googlegroups.com
#35749: AlterIndexTogether raising TypeError: 'class Meta' got invalid
attribute(s): index_together
-------------------------------------+-------------------------------------
Reporter: Dishen Wang | Owner: (none)
Type: Bug | Status: closed
Component: Migrations | Version: 5.1
Severity: Normal | Resolution: duplicate
Keywords: AlterIndexTogether, | Triage Stage:
index_together | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Natalia Bidart):

* resolution: => duplicate
* status: new => closed

Comment:

Hola Andrés! I understand that you may feel frustrated by this but please
do not reopen tickets closed by maintainers/Fellows, unless those are in
`needsinfo` state and the reopening includes the requested extra
information.

My advice at this point is that, if you disagree with the ticket
resolution and/or want extra opinions on this matter, please consider
starting a new conversation on the
[https://forum.djangoproject.com/c/internals/5 Django Forum], where you'll
reach a broader audience and receive additional feedback.
--
Ticket URL: <https://code.djangoproject.com/ticket/35749#comment:6>

Django

unread,
Nov 15, 2024, 8:49:10 AM11/15/24
to django-...@googlegroups.com
#35749: AlterIndexTogether raising TypeError: 'class Meta' got invalid
attribute(s): index_together
-------------------------------------+-------------------------------------
Reporter: Dishen Wang | Owner: (none)
Type: Bug | Status: closed
Component: Migrations | Version: 5.1
Severity: Normal | Resolution: duplicate
Keywords: AlterIndexTogether, | Triage Stage:
index_together | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Tim Graham):

I agree this matter is confusing and at least requires a documentation
clarification. See ticket:34856#comment:5. I do not understand what
backward compatibility purpose `AlterIndexTogether` serves when all it
does is crash.
--
Ticket URL: <https://code.djangoproject.com/ticket/35749#comment:7>

Django

unread,
Nov 15, 2024, 10:08:56 AM11/15/24
to django-...@googlegroups.com
#35749: AlterIndexTogether raising TypeError: 'class Meta' got invalid
attribute(s): index_together
-------------------------------------+-------------------------------------
Reporter: Dishen Wang | Owner: (none)
Type: Bug | Status: closed
Component: Migrations | Version: 5.1
Severity: Normal | Resolution: duplicate
Keywords: AlterIndexTogether, | Triage Stage:
index_together | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Simon Charette):

I agree that we need to have a large discussion on what can be done to
reduce the friction here given the state of things and how far we are in
the release and deprecation process. I believe
[https://forum.djangoproject.com/t/django-5-1-alterindextogether-raising-
typeerror-class-meta-got-invalid-attribute-s-index-together/36450 this
forum thread] is likely the best location to discuss this further so I
plan on providing my thoughts over there by EoD.
--
Ticket URL: <https://code.djangoproject.com/ticket/35749#comment:8>
Reply all
Reply to author
Forward
0 new messages