I'm new to South and I'm trying to perform a migration. It worked fine in local, but when I pushed the code to Heroku and tried to migrate I got this error:
Traceback (most recent call last):
File "manage.py", line 57, in <module>
execute_from_command_line()
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 443, in execute_from_command_line
utility.execute()
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/base.py", line 196, in run_from_argv
self.execute(*args, **options.__dict__)
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/base.py", line 232, in execute
output = self.handle(*args, **options)
File "/app/.heroku/python/lib/python2.7/site-packages/south/management/commands/migrate.py", line 111, in handle
ignore_ghosts = ignore_ghosts,
File "/app/.heroku/python/lib/python2.7/site-packages/south/migration/__init__.py", line 200, in migrate_app
applied_all = check_migration_histories(applied_all, delete_ghosts, ignore_ghosts)
File "/app/.heroku/python/lib/python2.7/site-packages/south/migration/__init__.py", line 81, in check_migration_histories
m = h.get_migration()
File "/app/.heroku/python/lib/python2.7/site-packages/south/models.py", line 34, in get_migration
return self.get_migrations().migration(self.migration)
File "/app/.heroku/python/lib/python2.7/site-packages/south/models.py", line 31, in get_migrations
return Migrations(self.app_name)
File "/app/.heroku/python/lib/python2.7/site-packages/south/migration/base.py", line 64, in __call__
self.instances[app_label] = super(MigrationsMetaclass, self).__call__(app_label_to_app_module(app_label), **kwds)
File "/app/.heroku/python/lib/python2.7/site-packages/south/migration/base.py", line 90, in __init__
self.set_application(application, force_creation, verbose_creation)
File "/app/.heroku/python/lib/python2.7/site-packages/south/migration/base.py", line 162, in set_application
raise exceptions.NoMigrations(application)
south.exceptions.NoMigrations: Application '<module 'django_extensions' from '/app/.heroku/python/lib/python2.7/site-packages/django_extensions/__init__.pyc'>' has no migrations.
In local I did:
python manage.py schemamigration spicemodels --auto
python manage.py migrate spicemodels
Then I pushed the migration files to Heroku and accessed the app using:
heroku run bash --app <app-name>
I then went into the correct directory and ran:
python manage.py migrate spicemodels
That is when I got the error above.
Related
I made a completely new project using the django-admin startproject and I also made an app using django-admin startapp and I am able to apply the initial migrations but not able to do the migrate. and I didn't add any code into the project. It's completely a new project.
python manage.py migrate
Operations to perform:
Apply all migrations: admin, auth, contenttypes, sessions
Running migrations:
Applying auth.0013_user_following...Traceback (most recent call last):
File "G:\My Drive\Django 4 by example\myshop\manage.py", line 22, in <module>
main()
File "G:\My Drive\Django 4 by example\myshop\manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "C:\Users\admin\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\management\__init__.py", line 446, in execute_from_command_line
utility.execute()
File "C:\Users\admin\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\management\__init__.py", line 440, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\admin\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\management\base.py", line 402, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\admin\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\management\base.py", line 448, in execute
output = self.handle(*args, **options)
File "C:\Users\admin\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\management\base.py", line 96, in wrapped
res = handle_func(*args, **kwargs)
File "C:\Users\admin\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\management\commands\migrate.py", line 349, in handle
post_migrate_state = executor.migrate(
File "C:\Users\admin\AppData\Local\Programs\Python\Python310\lib\site-packages\django\db\migrations\executor.py", line 135, in migrate
state = self._migrate_all_forwards(
File "C:\Users\admin\AppData\Local\Programs\Python\Python310\lib\site-packages\django\db\migrations\executor.py", line 167, in _migrate_all_forwards
state = self.apply_migration(
File "C:\Users\admin\AppData\Local\Programs\Python\Python310\lib\site-packages\django\db\migrations\executor.py", line 252, in apply_migration
state = migration.apply(state, schema_editor)
File "C:\Users\admin\AppData\Local\Programs\Python\Python310\lib\site-packages\django\db\migrations\migration.py", line 130, in apply
operation.database_forwards(
File "C:\Users\admin\AppData\Local\Programs\Python\Python310\lib\site-packages\django\db\migrations\operations\fields.py", line 108, in database_forwards
schema_editor.add_field(
File "C:\Users\admin\AppData\Local\Programs\Python\Python310\lib\site-packages\django\db\backends\sqlite3\schema.py", line 383, in add_field
if field.many_to_many and field.remote_field.through._meta.auto_created:
AttributeError: 'str' object has no attribute '_meta'
I uninstalled all the packages which I installed for the project, uninstalled Django as well, and deleted all the migrations of all the projects but still it's not working.
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
I'm developing a project with Django CMS 3.5. I used SQLite for development and have data in there. Now I'm trying to migrate to PostgreSQL. My steps so far:
python manage.py dumpdata --natural-primary --natural-foreign > dump.json
Switching to production settings
python manage.py migrate
TRUNCATE django_content_type CASCADE;
python manage.py loaddata dump.json
But I encounter the next error:
Traceback (most recent call last):
File "/home/webmaster/tc56/env/lib/python3.6/site-packages/django/db/models/fields/related_descriptors.py", line 178, in __get__
rel_obj = getattr(instance, self.cache_name)
AttributeError: 'Page' object has no attribute '_node_cache'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "/home/webmaster/tc56/env/lib/python3.6/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
utility.execute()
File "/home/webmaster/tc56/env/lib/python3.6/site-packages/django/core/management/__init__.py", line 356, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/webmaster/tc56/env/lib/python3.6/site-packages/django/core/management/base.py", line 283, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/webmaster/tc56/env/lib/python3.6/site-packages/django/core/management/base.py", line 330, in execute
output = self.handle(*args, **options)
File "/home/webmaster/tc56/env/lib/python3.6/site-packages/django/core/management/commands/loaddata.py", line 69, in handle
self.loaddata(fixture_labels)
File "/home/webmaster/tc56/env/lib/python3.6/site-packages/django/core/management/commands/loaddata.py", line 109, in loaddata
self.load_label(fixture_label)
File "/home/webmaster/tc56/env/lib/python3.6/site-packages/django/core/management/commands/loaddata.py", line 175, in load_label
obj.save(using=self.using)
File "/home/webmaster/tc56/env/lib/python3.6/site-packages/django/core/serializers/base.py", line 205, in save
models.Model.save_base(self.object, using=using, raw=True, **kwargs)
File "/home/webmaster/tc56/env/lib/python3.6/site-packages/django/db/models/base.py", line 833, in save_base
update_fields=update_fields,
File "/home/webmaster/tc56/env/lib/python3.6/site-packages/django/dispatch/dispatcher.py", line 193, in send
for receiver in self._live_receivers(sender)
File "/home/webmaster/tc56/env/lib/python3.6/site-packages/django/dispatch/dispatcher.py", line 193, in <listcomp>
for receiver in self._live_receivers(sender)
File "/home/webmaster/tc56/env/lib/python3.6/site-packages/cms/signals/page.py", line 8, in pre_save_page
instance.clear_cache(menu=True)
File "/home/webmaster/tc56/env/lib/python3.6/site-packages/cms/models/pagemodel.py", line 963, in clear_cache
menu_pool.clear(site_id=self.node.site_id)
File "/home/webmaster/tc56/env/lib/python3.6/site-packages/django/db/models/fields/related_descriptors.py", line 184, in __get__
rel_obj = self.get_object(instance)
File "/home/webmaster/tc56/env/lib/python3.6/site-packages/django/db/models/fields/related_descriptors.py", line 159, in get_object
return qs.get(self.field.get_reverse_related_filter(instance))
File "/home/webmaster/tc56/env/lib/python3.6/site-packages/django/db/models/query.py", line 380, in get
self.model._meta.object_name
cms.models.pagemodel.DoesNotExist: Problem installing fixture '/home/webmaster/tc56/dump.json': TreeNode matching query does not exist.
This was fixed a few days ago.
Will land with django CMS 3.5.3
I have a Django project setup under virtualenv, and have a empty tests.py under the project folder.
When I do "python manage.py test", I am getting the following error:
Traceback (most recent call last):
File "manage.py", line 12, in <module>
execute_from_command_line(sys.argv)
File "/Users/dj_prj/dj_prj/env/lib/python2.7/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
utility.execute()
File "/Users/dj_prj/dj_prj/env/lib/python2.7/site-packages/django/core/management/__init__.py", line 377, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/dj_prj/dj_prj/env/lib/python2.7/site-packages/django/core/management/commands/test.py", line 50, in run_from_argv
super(Command, self).run_from_argv(argv)
File "/Users/dj_prj/dj_prj/env/lib/python2.7/site-packages/django/core/management/base.py", line 288, in run_from_argv
self.execute(*args, **options.__dict__)
File "/Users/dj_prj/dj_prj/env/lib/python2.7/site-packages/django/core/management/commands/test.py", line 71, in execute
super(Command, self).execute(*args, **options)
File "/Users/dj_prj/dj_prj/env/lib/python2.7/site-packages/django/core/management/base.py", line 338, in execute
output = self.handle(*args, **options)
File "/Users/dj_prj/dj_prj/env/lib/python2.7/site-packages/django/core/management/commands/test.py", line 88, in handle
failures = test_runner.run_tests(test_labels)
File "/Users/dj_prj/dj_prj/oicms/test/oicms_test_runner.py", line 209, in run_tests
suite = self.build_suite(test_labels, extra_tests)
File "/Users/dj_prj/dj_prj/oicms/test/oicms_test_runner.py", line 150, in build_suite
tests = self.test_loader.discover(start_dir=label, **kwargs)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/loader.py", line 206, in discover
tests = list(self._find_tests(start_dir, pattern))
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/loader.py", line 267, in _find_tests
raise ImportError(msg % (mod_name, module_dir, expected_dir))
ImportError: 'tests' module incorrectly imported from '/Users/dj_prj/dj_prj/dj_prj'. Expected '/Users/dj_prj/dj_prj/'. Is this module globally installed?
What is your environment?
Your problem may be related to this one:
Django test runner fails in virtualenv on Ubuntu
I try to deploy app on Heroku but after running command 'heroku run python manage.py migrate' I get an error:
Running `python manage.py migrate` attached to terminal... up, run.5928
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
utility.execute()
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 377, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/base.py", line 288, in run_from_argv
self.execute(*args, **options.__dict__)
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/base.py", line 338, in execute
output = self.handle(*args, **options)
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 63, in handle
executor = MigrationExecutor(connection, self.migration_progress_callback)
File "/app/.heroku/python/lib/python2.7/site-packages/django/db/migrations/executor.py", line 17, in __init__
self.loader = MigrationLoader(self.connection)
File "/app/.heroku/python/lib/python2.7/site-packages/django/db/migrations/loader.py", line 48, in __init__
self.build_graph()
File "/app/.heroku/python/lib/python2.7/site-packages/django/db/migrations/loader.py", line 173, in build_graph
self.load_disk()
File "/app/.heroku/python/lib/python2.7/site-packages/django/db/migrations/loader.py", line 103, in load_disk
migration_module = import_module("%s.%s" % (module_name, migration_name))
File "/app/.heroku/python/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/app/joins/migrations/0004_auto_20150211_1924.py", line 7, in <module>
class Migration(migrations.Migration):
File "/app/joins/migrations/0004_auto_20150211_1924.py", line 18, in Migration
preserve_default=True,
TypeError: __init__() got an unexpected keyword argument 'preserve_default'
Do you have any suggestion?
You can try to see this :
Django 1.7.1 added support for the preserve_default param in AlterField. Therefore an upgrade of Django from version 1.7 will resolve the issue.
pip install django --upgrade
python manage.py migrate
From : Django 1.7 Migrations
.