Django verstion 1.8
Trying to migrate a newly added app in my project. Here is the traceback error:
Traceback (most recent call last):
File "./manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 354, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 346, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 394, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 445, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/makemigrations.py", line 63, in handle
loader = MigrationLoader(None, ignore_no_migrations=True)
File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/loader.py", line 47, in __init__
self.build_graph()
File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/loader.py", line 318, in build_graph
_reraise_missing_dependency(migration, parent, e)
File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/loader.py", line 288, in _reraise_missing_dependency
raise exc
django.db.migrations.graph.NodeNotFoundError: Migration weather.0001_initial dependencies reference nonexistent parent node (u'machines', u'0006_auto_20150921_1327')
I have not found much helpful information in researching this. Syntax is correct in all models. Here is what doesn't make sense: this is just a copy of a working project. So it works on one computer, but not here. The machines model it's referencing has already been created and is working. Any ideas???
You are getting the error because the migration you are trying to run, weather.0001_initial, depends on a migration machines.0006_auto_20150921_1327 which does not exist.
If you can't find the missing migration file, you'll have to delete and recreate the migrations for the weather app, so that they don't depend on the missing migration.
You are getting this error because you are missing the
__init__.py
file in your migrations folder.
For me, it worked after adding this file.
Related
I'm trying to deploy my app on PythonAnywhere and when i go to apply the migrations i get an error that a migration dependency does not exist.
I've completely reset the migrations by deleting them from the migrations folder, dropping the database and re-creating it, and running makemigrations.
I only have my one initial migration now and everything works on my local machine.
workflow goes like this:
1 - clone the current version I'm using to PythonAnywhere.
2 - run ./manage migrate to initialize the database (the very first time) and get error:
(rwe) 17:00 ~/rwe (develop)$ ./manage.py migrate
asyncio DEBUG Using selector: EpollSelector
Traceback (most recent call last):
File "./manage.py", line 21, in <module>
main()
File "./manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "/home/IAMCB/.virtualenvs/rwe-Cn2YEGYr/lib/python3.7/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
utility.execute()
File "/home/IAMCB/.virtualenvs/rwe-Cn2YEGYr/lib/python3.7/site-packages/django/core/management/__init__.py", line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/IAMCB/.virtualenvs/rwe-Cn2YEGYr/lib/python3.7/site-packages/django/core/management/base.py", line 328, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/IAMCB/.virtualenvs/rwe-Cn2YEGYr/lib/python3.7/site-packages/django/core/management/base.py", line 369, in execute
output = self.handle(*args, **options)
File "/home/IAMCB/.virtualenvs/rwe-Cn2YEGYr/lib/python3.7/site-packages/django/core/management/base.py", line 83, in wrapped
res = handle_func(*args, **kwargs)
File "/home/IAMCB/.virtualenvs/rwe-Cn2YEGYr/lib/python3.7/site-packages/django/core/management/commands/migrate.py", line 86, in handle
executor = MigrationExecutor(connection, self.migration_progress_callback)
File "/home/IAMCB/.virtualenvs/rwe-Cn2YEGYr/lib/python3.7/site-packages/django/db/migrations/executor.py", line 18, in __init__
self.loader = MigrationLoader(self.connection)
File "/home/IAMCB/.virtualenvs/rwe-Cn2YEGYr/lib/python3.7/site-packages/django/db/migrations/loader.py", line 49, in __init__
self.build_graph()
File "/home/IAMCB/.virtualenvs/rwe-Cn2YEGYr/lib/python3.7/site-packages/django/db/migrations/loader.py", line 274, in build_graph
raise exc
File "/home/IAMCB/.virtualenvs/rwe-Cn2YEGYr/lib/python3.7/site-packages/django/db/migrations/loader.py", line 248, in build_graph
self.graph.validate_consistency()
File "/home/IAMCB/.virtualenvs/rwe-Cn2YEGYr/lib/python3.7/site-packages/django/db/migrations/graph.py", line 195, in validate_consistency
[n.raise_error() for n in self.node_map.values() if isinstance(n, DummyNode)]
File "/home/IAMCB/.virtualenvs/rwe-Cn2YEGYr/lib/python3.7/site-packages/django/db/migrations/graph.py", line 195, in <listcomp>
[n.raise_error() for n in self.node_map.values() if isinstance(n, DummyNode)]
File "/home/IAMCB/.virtualenvs/rwe-Cn2YEGYr/lib/python3.7/site-packages/django/db/migrations/graph.py", line 58, in raise_error
raise NodeNotFoundError(self.error_message, self.key, origin=self.origin)
django.db.migrations.exceptions.NodeNotFoundError: Migration backend.0001_initial dependencies reference nonexistent parent node ('auth', '0013_delete_users')
(rwe) 17:12 ~/rwe (develop)$
The website loads, and I can browse, etc.. I just can't use anything that relies on the database considering the initial migration hasn't been applied.
The only real change between the systems is the secret key is different for production and DEBUG=False
I figured it out.
I updated django from 2.2.3 to 3.0.3 and the migrations I am missing must have generated during my use of 2.2.3.
worked for me but not for my PythonAnywhere server. I've recreated my virtualenv on my dev machine and reset all my migrations. Everything is now matching up without issue.
I cannot "makemigrations" in my Django project. When I try to do
"python manage.py makemigrations"
It shows the following
Traceback (most recent call last):
File "manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "/home/ani/Desktop/Backup/venv/lib/python3.7/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/home/ani/Desktop/Backup/venv/lib/python3.7/site-packages/django/core/management/__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/ani/Desktop/Backup/venv/lib/python3.7/site-packages/django/core/management/base.py", line 316, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/ani/Desktop/Backup/venv/lib/python3.7/site-packages/django/core/management/base.py", line 353, in execute
output = self.handle(*args, **options)
File "/home/ani/Desktop/Backup/venv/lib/python3.7/site-packages/django/core/management/base.py", line 83, in wrapped
res = handle_func(*args, **kwargs)
File "/home/ani/Desktop/Backup/venv/lib/python3.7/site-packages/django/core/management/commands/makemigrations.py", line 89, in handle
loader = MigrationLoader(None, ignore_no_migrations=True)
File "/home/ani/Desktop/Backup/venv/lib/python3.7/site-packages/django/db/migrations/loader.py", line 49, in __init__
self.build_graph()
File "/home/ani/Desktop/Backup/venv/lib/python3.7/site-packages/django/db/migrations/loader.py", line 273, in build_graph
raise exc
File "/home/ani/Desktop/Backup/venv/lib/python3.7/site-packages/django/db/migrations/loader.py", line 247, in build_graph
self.graph.validate_consistency()
File "/home/ani/Desktop/Backup/venv/lib/python3.7/site-packages/django/db/migrations/graph.py", line 243, in validate_consistency
[n.raise_error() for n in self.node_map.values() if isinstance(n, DummyNode)]
File "/home/ani/Desktop/Backup/venv/lib/python3.7/site-packages/django/db/migrations/graph.py", line 243, in <listcomp>
[n.raise_error() for n in self.node_map.values() if isinstance(n, DummyNode)]
File "/home/ani/Desktop/Backup/venv/lib/python3.7/site-packages/django/db/migrations/graph.py", line 96, in raise_error
raise NodeNotFoundError(self.error_message, self.key, origin=self.origin)
django.db.migrations.exceptions.NodeNotFoundError: Migration djoser.0001_initial dependencies reference nonexistent parent node ('auth', '0011_update_proxy_permissions')
I tried installing mysqlclient and creating the database all over again but then it doesn't work at all.
Your migrations directory is broken. Django creates migrations files for each migration (each time you type makemigration.
Currently, one of your migrations file has something like:
dependencies = [
('accounts', '0011_update_proxy_permissions'),
]
And migrations/0011_update_proxy_permissions.py doesn't exist. You need either edit this migration manually or remove everything in migrations directory and run makemigrations from scratch. If you remove migrations you will also need to drop the database so django would create it from the scratch.
There're a lot of articles out there that would help you to investigate your issue further. Like this one
When I try to run migration I get "Migration urls in app *** has no Migration class"? I just added new app.
Have no idea what direction to look. Traceback:
C:\Users\PAPA\DEV\liberty\lib\site-packages\django\db\models\__init__.py:55:
RemovedInDjango19Warning: The utilities in django.db.models.loading are deprecated
in favor of the new application loading system.
from . import loading
Traceback (most recent call last): File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "...\django\core\management\__init__.py", line 338, in execute_from_command_line
utility.execute()
File "...\django\core\management\__init__.py", line 330, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "...\django\core\management\base.py", line 390, in run_from_argv
self.execute(*args, **cmd_options)
File "...\django\core\management\base.py", line 441, in execute
output = self.handle(*args, **options)
File "...\django\core\management\commands\makemigrations.py", line 63, in handle
loader = MigrationLoader(None, ignore_no_migrations=True)
File "...\django\db\migrations\loader.py", line 47, in __init__
self.build_graph()
File "...\django\db\migrations\loader.py", line 174, in build_graph
self.load_disk()
File "...\django\db\migrations\loader.py", line 109, in load_disk
"Migration %s in app %s has no Migration class" % (migration_name, app_config.label)
django.db.migrations.loader.BadMigrationError: Migration urls in app expense has no
Migration class
That exception
BadMigrationError: "Migration *** in app *** has no Migration class"
is raised if the "migrations/" directory of the application contains a file that is not a valid migration file.
In your case it is a file "urls.py" in migrations of the application "expense".
I'm getting the following error trying to migrate for the first time a project using django 1.7.1. How can I debug this?
mariano#mariano-System-Product-Name:~/PycharmProjects/grupoconsultor-arg$ python manage.py migrate --settings='xxx.settings_dev'
Traceback (most recent call last):
File "manage.py", line 13, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 377, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 288, in run_from_argv
self.execute(*args, **options.__dict__)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 337, in execute
self.check()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 371, in check
all_issues = checks.run_checks(app_configs=app_configs, tags=tags)
File "/usr/local/lib/python2.7/dist-packages/django/core/checks/registry.py", line 59, in run_checks
new_errors = check(app_configs=app_configs)
File "/usr/local/lib/python2.7/dist-packages/django/core/checks/model_checks.py", line 28, in check_all_models
errors.extend(model.check(**kwargs))
TypeError: unbound method check() must be called with server instance as first argument (got nothing instead)
better late than never ;-)
see https://code.djangoproject.com/ticket/22526,
look for check() method in your server model and change name
I am getting an error trying to apply a first South migration. I have tried various suggestions (like removing .pyc files in the migrations folder, converting the app as well as trying to start it afresh, other fiddles). Can anyone here suggest what I might do? Thanks
(env)~/code/django/ssc/dev/ssc/ssc> python manage.py migrate
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 443, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 196, in run_from_argv
self.execute(*args, **options.__dict__)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 232, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python2.7/dist-packages/south/management/commands/migrate.py", line 108, in handle
ignore_ghosts = ignore_ghosts,
File "/usr/local/lib/python2.7/dist-packages/south/migration/__init__.py", line 166, in migrate_app
Migrations.calculate_dependencies()
File "/usr/local/lib/python2.7/dist-packages/south/migration/base.py", line 228, in calculate_dependencies
migration.calculate_dependencies()
File "/usr/local/lib/python2.7/dist-packages/south/migration/base.py", line 362, in calculate_dependencies
for migration in self._get_dependency_objects("depends_on"):
File "/usr/local/lib/python2.7/dist-packages/south/migration/base.py", line 342, in _get_dependency_objects
for app, name in getattr(self.migration_class(), attrname, []):
File "/usr/local/lib/python2.7/dist-packages/south/migration/base.py", line 314, in migration_class
return self.migration().Migration
AttributeError: 'module' object has no attribute 'Migration'
(env)~/code/django/ssc/dev/ssc/ssc> python manage.py convert_to_south crewcal
This application is already managed by South.
(env)~/code/django/ssc/dev/ssc/ssc> python manage.py migrateTraceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 443, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 196, in run_from_argv
self.execute(*args, **options.__dict__)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 232, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python2.7/dist-packages/south/management/commands/migrate.py", line 108, in handle
ignore_ghosts = ignore_ghosts,
File "/usr/local/lib/python2.7/dist-packages/south/migration/__init__.py", line 166, in migrate_app
Migrations.calculate_dependencies()
File "/usr/local/lib/python2.7/dist-packages/south/migration/base.py", line 228, in calculate_dependencies
migration.calculate_dependencies()
File "/usr/local/lib/python2.7/dist-packages/south/migration/base.py", line 362, in calculate_dependencies
for migration in self._get_dependency_objects("depends_on"):
File "/usr/local/lib/python2.7/dist-packages/south/migration/base.py", line 342, in _get_dependency_objects
for app, name in getattr(self.migration_class(), attrname, []):
File "/usr/local/lib/python2.7/dist-packages/south/migration/base.py", line 314, in migration_class
return self.migration().Migration
AttributeError: 'module' object has no attribute 'Migration'
In my case the AttributeError: 'module' object has no attribute 'Migration' error was simply a matter of having an extra .py file in my migrations folder.
I had an extra utilities module in my migrations directory which caused South to choke. Moving the module into a different directory (above my apps migrations directory) solved the problem for me.
Maybe a bit late, but still...
Is it possible you have any other package (folder with __init__.py) in your migration package and it interferes with the structure?
Wow. I was getting the AttributeError: 'module' object has no attribute 'Migration' error for a completely different reason than the above answers.
I had a migration file which had a bad indent:
class Migration(SchemaMigration):
def forwards(self, orm):
#
def backwards(self, orm):
#
models = {...}
As opposed to ...
class Migration(SchemaMigration):
def forwards(self, orm):
#
def backwards(self, orm):
#
models = {...}
I don't know why I had that but when I fixed that the error was gone.