Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#24848 closed Bug (fixed)

makemigrations fails with 'ValueError: Dependency on unknown app' when migrations module exists without __init__.py

Reported by: Petros Moisiadis Owned by: Marten Kenbeek
Component: Migrations Version: 1.8
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Django version 1.8.2

traceback:

Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/path/to/python/env/lib/python3.4/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
    utility.execute()
  File "/path/to/python/env/lib/python3.4/site-packages/django/core/management/__init__.py", line 330, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/path/to/python/env/lib/python3.4/site-packages/django/core/management/base.py", line 390, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/path/to/python/env/lib/python3.4/site-packages/django/core/management/base.py", line 441, in execute
    output = self.handle(*args, **options)
  File "/path/to/python/env/lib/python3.4/site-packages/django/core/management/commands/makemigrations.py", line 63, in handle
    loader = MigrationLoader(None, ignore_no_migrations=True)
  File "/path/to/python/env/lib/python3.4/site-packages/django/db/migrations/loader.py", line 47, in __init__
    self.build_graph()
  File "/path/to/python/env/lib/python3.4/site-packages/django/db/migrations/loader.py", line 287, in build_graph
    parent = self.check_key(parent, key[0])
  File "/path/to/python/env/lib/python3.4/site-packages/django/db/migrations/loader.py", line 165, in check_key
    raise ValueError("Dependency on unknown app: %s" % key[0])
ValueError: Dependency on unknown app: users

Example project is included as an attachment.

Attachments (1)

myproject.tar.gz (3.6 KB) - added by Petros Moisiadis 4 years ago.

Download all attachments as: .zip

Change History (5)

Changed 4 years ago by Petros Moisiadis

Attachment: myproject.tar.gz added

comment:1 Changed 4 years ago by Marten Kenbeek

Owner: changed from nobody to Marten Kenbeek
Status: newassigned
Summary: makemigrations fails with 'ValueError: Dependency on unknown app' when using custom user modelmakemigrations fails with 'ValueError: Dependency on unknown app' when migrations module exists without __init__.py
Triage Stage: UnreviewedAccepted

The problem is that, if you hit https://github.com/django/django/blob/master/django/db/migrations/loader.py#L81 due to a missing __init__.py file, the app is neither in migrated_apps nor unmigrated_apps. The same will happen if the migrations module is a file, and not a folder.

comment:2 Changed 4 years ago by Marten Kenbeek

Has patch: set

comment:3 Changed 4 years ago by Tim Graham <timograham@…>

Resolution: fixed
Status: assignedclosed

In d73176a8:

Fixed #24848 -- Fixed ValueError for faulty migrations module.

Added apps to unmigrated apps if the migrations module is a file
or a folder missing init.py.

Thanks to Ernest0x for the bug report.

comment:4 Changed 4 years ago by Tim Graham <timograham@…>

In 1ac4c7d4:

[1.8.x] Fixed #24848 -- Fixed ValueError for faulty migrations module.

Added apps to unmigrated apps if the migrations module is a file
or a folder missing init.py.

Thanks to Ernest0x for the bug report.

Backport of d73176a84273c06fa11075c65293ec28497a8423 from master

Note: See TracTickets for help on using tickets.
Back to Top