Opened 5 months ago

Last modified 5 months ago

#35545 closed Bug

Fix create_permissions LookupErrors — at Version 1

Reported by: Csirmaz Bendegúz Owned by: nobody
Component: contrib.auth Version: 5.1
Severity: Release blocker Keywords:
Cc: Adam Johnson, Mariusz Felisiak, Simon Charette Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Csirmaz Bendegúz)

#35408 introduced a bug in contrib.auth's create_permissions function (PR, commit d2c5a30e5a8595d06c4a70ff0f66032fee0d3c8e).
Since this function is called by the post_migrate signal, it affects the migrate command.
The function raises unexpected LookupError s on Windows systems.

Operations to perform:
  Apply all migrations: admin, auth, contenttypes, dev, sessions
Running migrations:
  Applying dev.0001_initial... OK
Traceback (most recent call last):
  File "C:\Users\csirm\PycharmProjects\django-dev\venv\Lib\site-packages\django\apps\registry.py", line 158, in get_app_config
    return self.app_configs[app_label]
           ~~~~~~~~~~~~~~~~^^^^^^^^^^^
KeyError: 'dev'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\csirm\PycharmProjects\django-dev\django_dev\manage.py", line 22, in <module>
    main()
  File "C:\Users\csirm\PycharmProjects\django-dev\django_dev\manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "C:\Users\csirm\PycharmProjects\django-dev\venv\Lib\site-packages\django\core\management\__init__.py", line 442, in execute_from_command_line
    utility.execute()
  File "C:\Users\csirm\PycharmProjects\django-dev\venv\Lib\site-packages\django\core\management\__init__.py", line 436, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Users\csirm\PycharmProjects\django-dev\venv\Lib\site-packages\django\core\management\base.py", line 413, in run_from_argv
    self.execute(*args, **cmd_options)
  File "C:\Users\csirm\PycharmProjects\django-dev\venv\Lib\site-packages\django\core\management\base.py", line 459, in execute
    output = self.handle(*args, **options)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\csirm\PycharmProjects\django-dev\venv\Lib\site-packages\django\core\management\base.py", line 107, in wrapper
    res = handle_func(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\csirm\PycharmProjects\django-dev\venv\Lib\site-packages\django\core\management\commands\migrate.py", line 384, in handle
    emit_post_migrate_signal(
  File "C:\Users\csirm\PycharmProjects\django-dev\venv\Lib\site-packages\django\core\management\sql.py", line 52, in emit_post_migrate_signal
    models.signals.post_migrate.send(
  File "C:\Users\csirm\PycharmProjects\django-dev\venv\Lib\site-packages\django\dispatch\dispatcher.py", line 189, in send
    response = receiver(signal=self, sender=sender, **named)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\csirm\PycharmProjects\django-dev\venv\Lib\site-packages\django\contrib\auth\management\__init__.py", line 78, in create_permissions
    ctypes = ContentType.objects.db_manager(using).get_for_models(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\csirm\PycharmProjects\django-dev\venv\Lib\site-packages\django\contrib\contenttypes\models.py", line 93, in get_for_models
    ct._meta.apps.get_model(ct.app_label, ct.model)._meta, []
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\csirm\PycharmProjects\django-dev\venv\Lib\site-packages\django\apps\registry.py", line 208, in get_model
    app_config = self.get_app_config(app_label)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\csirm\PycharmProjects\django-dev\venv\Lib\site-packages\django\apps\registry.py", line 165, in get_app_config
    raise LookupError(message)
LookupError: No installed app with label 'dev'.

Change History (1)

comment:1 by Csirmaz Bendegúz, 5 months ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top