#35424: Migration autodetector fails when order_with_respect_to is removed, but 
an
_order field remains
------------------------------------+--------------------------------------
     Reporter:  Stuart Attenborrow  |                    Owner:  nobody
         Type:  Bug                 |                   Status:  closed
    Component:  Migrations          |                  Version:  4.2
     Severity:  Normal              |               Resolution:  worksforme
     Keywords:                      |             Triage Stage:  Unreviewed
    Has patch:  0                   |      Needs documentation:  0
  Needs tests:  0                   |  Patch needs improvement:  0
Easy pickings:  1                   |                    UI/UX:  0
------------------------------------+--------------------------------------
Comment (by Stuart Attenborrow):

 Error shown below. I've added a zip that contains the same project, but
 with docker compose, and a poetry lock file to ensure we're looking at the
 same thing. Note I can reproduce this both in a docker container, and on a
 production EC2 instance using system python and virtual envs.

 {{{
 /code/mysite# python manage.py migrate
 Operations to perform:
   Apply all migrations: admin, auth, contenttypes, polls, sessions
 Running migrations:
   No migrations to apply.
 Traceback (most recent call last):
   File "/code/mysite/manage.py", line 22, in <module>
     main()
   File "/code/mysite/manage.py", line 18, in main
     execute_from_command_line(sys.argv)
   File "/opt/venv/lib/python3.11/site-
 packages/django/core/management/__init__.py", line 442, in
 execute_from_command_line
     utility.execute()
   File "/opt/venv/lib/python3.11/site-
 packages/django/core/management/__init__.py", line 436, in execute
     self.fetch_command(subcommand).run_from_argv(self.argv)
   File "/opt/venv/lib/python3.11/site-
 packages/django/core/management/base.py", line 412, in run_from_argv
     self.execute(*args, **cmd_options)
   File "/opt/venv/lib/python3.11/site-
 packages/django/core/management/base.py", line 458, in execute
     output = self.handle(*args, **options)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   File "/opt/venv/lib/python3.11/site-
 packages/django/core/management/base.py", line 106, in wrapper
     res = handle_func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   File "/opt/venv/lib/python3.11/site-
 packages/django/core/management/commands/migrate.py", line 335, in handle
     changes = autodetector.changes(graph=executor.loader.graph)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   File "/opt/venv/lib/python3.11/site-
 packages/django/db/migrations/autodetector.py", line 46, in changes
     changes = self._detect_changes(convert_apps, graph)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   File "/opt/venv/lib/python3.11/site-
 packages/django/db/migrations/autodetector.py", line 197, in
 _detect_changes
     self.generate_altered_fields()
   File "/opt/venv/lib/python3.11/site-
 packages/django/db/migrations/autodetector.py", line 1117, in
 generate_altered_fields
     old_field = self.from_state.models[app_label,
 old_model_name].get_field(
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   File "/opt/venv/lib/python3.11/site-
 packages/django/db/migrations/state.py", line 765, in get_field
     return self.fields[field_name]
            ~~~~~~~~~~~^^^^^^^^^^^^
 KeyError: None
 }}}
-- 
Ticket URL: <https://code.djangoproject.com/ticket/35424#comment:5>
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018f503705bf-94de455a-384a-458d-82a5-69ba9dbcd701-000000%40eu-central-1.amazonses.com.

Reply via email to