Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling of Apps without Migrations #23

Closed
psyonara opened this issue Dec 15, 2020 · 1 comment · Fixed by #24
Closed

Handling of Apps without Migrations #23

psyonara opened this issue Dec 15, 2020 · 1 comment · Fixed by #24

Comments

@psyonara
Copy link

When you have apps in your Django project that do not have migrations (i.e. apps without any data models), running the migrations causes this error:

Traceback (most recent call last):
  File "manage.py", line 15, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 375, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python3.7/site-packages/django/core/management/commands/test.py", line 23, in run_from_argv
    super().run_from_argv(argv)
  File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 323, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 364, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python3.7/site-packages/django/core/management/commands/test.py", line 53, in handle
    failures = test_runner.run_tests(test_labels)
  File "/usr/local/lib/python3.7/site-packages/django/test/runner.py", line 632, in run_tests
    self.run_checks()
  File "/usr/local/lib/python3.7/site-packages/django/test/runner.py", line 570, in run_checks
    call_command('check', verbosity=self.verbosity)
  File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 148, in call_command
    return command.execute(*args, **defaults)
  File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 364, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python3.7/site-packages/django/core/management/commands/check.py", line 64, in handle
    fail_level=getattr(checks, options['fail_level']),
  File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 390, in check
    include_deployment_checks=include_deployment_checks,
  File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 377, in _run_checks
    return checks.run_checks(**kwargs)
  File "/usr/local/lib/python3.7/site-packages/django/core/checks/registry.py", line 72, in run_checks
    new_errors = check(app_configs=app_configs)
  File "/usr/local/lib/python3.7/site-packages/django_linear_migrations/apps.py", line 81, in check_max_migration_files
    migration_details = MigrationDetails(app_label)
  File "/usr/local/lib/python3.7/site-packages/django_linear_migrations/apps.py", line 43, in __init__
    self.migrations_module = import_module(self.migrations_module_name)
  File "/usr/local/lib/python3.7/importlib/__init__.py", line 118, in import_module
    if name.startswith('.'):
AttributeError: 'NoneType' object has no attribute 'startswith'

From looking at the DLM source code, it seems that a None value for the migrations module isn't handled correctly.
In apps.py:43 it tries to import the migrations module even if that app doesn't have one.

@adamchainz
Copy link
Owner

Fixed in #24, released in 1.2.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants