I am attempting to migrate my changes with command
python manage.py migrate
I have already ran the command,
python manage.py makemigrations accounts
which successfully returns,
Migrations for 'accounts':
accounts/migrations/0001_initial.py
- Create model CustomUser
Then in attempting to run python manage.py migrate I recieve this error...
Traceback (most recent call last):
File "/home/mycroft/C/news/manage.py", line 22, in <module>
main()
File "/home/mycroft/C/news/manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "/home/mycroft/.local/share/virtualenvs/news-ToLZWqxe/lib/python3.9/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
utility.execute()
File "/home/mycroft/.local/share/virtualenvs/news-ToLZWqxe/lib/python3.9/site-packages/django/core/management/__init__.py", line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/mycroft/.local/share/virtualenvs/news-ToLZWqxe/lib/python3.9/site-packages/django/core/management/base.py", line 330, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/mycroft/.local/share/virtualenvs/news-ToLZWqxe/lib/python3.9/site-packages/django/core/management/base.py", line 371, in execute
output = self.handle(*args, **options)
File "/home/mycroft/.local/share/virtualenvs/news-ToLZWqxe/lib/python3.9/site-packages/django/core/management/base.py", line 85, in wrapped
res = handle_func(*args, **kwargs)
File "/home/mycroft/.local/share/virtualenvs/news-ToLZWqxe/lib/python3.9/site-packages/django/core/management/commands/migrate.py", line 95, in handle
executor.loader.check_consistent_history(connection)
File "/home/mycroft/.local/share/virtualenvs/news-ToLZWqxe/lib/python3.9/site-packages/django/db/migrations/loader.py", line 302, in check_consistent_history
raise InconsistentMigrationHistory(
django.db.migrations.exceptions.InconsistentMigrationHistory: Migration admin.0001_initial is applied before its dependency accounts.0001_initial on database 'default'.
I am very new to django and can't seem to figure out just what I am doing wrong. Any help would be greatly appreciated!
Maybe you made some changes to you models.py file and these changes aren't sitting well with the inital db structure. If you can track and undo the recent changes it may help, else you'll have to drop your database, delete all migration files your account app. Then repeat the makemigration, migrate, and createsuperuser processes.
Related
Traceback :
File "manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "D:\Anaconda\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line
utility.execute()
File "D:\Anaconda\lib\site-packages\django\core\management\__init__.py", line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "D:\Anaconda\lib\site-packages\django\core\management\base.py", line 328, in run_from_argv
self.execute(*args, **cmd_options)
File "D:\Anaconda\lib\site-packages\django\core\management\base.py", line 369, in execute
output = self.handle(*args, **options)
File "D:\Anaconda\lib\site-packages\django\core\management\base.py", line 83, in wrapped
res = handle_func(*args, **kwargs)
File "D:\Anaconda\lib\site-packages\django\core\management\commands\makemigrations.py", line 87, in handle
loader = MigrationLoader(None, ignore_no_migrations=True)
File "D:\Anaconda\lib\site-packages\django\db\migrations\loader.py", line 49, in __init__
self.build_graph()
File "D:\Anaconda\lib\site-packages\django\db\migrations\loader.py", line 274, in build_graph
raise exc
File "D:\Anaconda\lib\site-packages\django\db\migrations\loader.py", line 248, in build_graph
self.graph.validate_consistency()
File "D:\Anaconda\lib\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 "D:\Anaconda\lib\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 "D:\Anaconda\lib\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 auth.0012_user_following dependencies reference nonexistent parent node ('account', '0002_contact')
pip freeze txt file link:
https://github.com/shyamparmar29/pip-freeze/blob/master/freeze.docx
There's no app named account in my project but i am still getting this error. I have tried to delete all pycache and migration files but it is not helping.
I even tried to run the project in a virtual environment but i am still getting this error.
Please help.
do these steps:
1- delete migrations folder in each app
2- delete database tables or simply delete it completely
3- run ./manage.py makemigrations appname for each app
4- run ./manage.py migrate
5- finally run the server and see what happens
if it does not work again see this.
edit:
delete your DB and run
python manage.py migrate --fake auth zero
then make migrations again.
You can try the following specific operations as follows:
Delete through the query path under the local python3.8 file:
https://i.stack.imgur.com/FMe2r.png ( reference )
Delete the migration file that is determined to be wrong, here is the last file starting with 0012.
Re-execute python3 manage.py makemigrations after deleting
Execute python3 manage.py migrate
At this point, the migration operation should be normal.
Note: You can also search and delete through the library under the pycharm project, the path is the same as above. It is easy to find and operate.
I am in the process of moving the django page to a new server. Due to complications in the apache server configuration, I used mod_wsgi-express integrated into virtualenv python. According to the instructions found on this page: https://pypi.org/project/mod-wsgi/#description , I added mod_wsgi.server to installed Django applications and run the command python manage.py runmodwsgi. Unfortunately, in response I get an error which pastes below. I would be very grateful for any help and explanation why this problem appeared.
Traceback (most recent call last):
File "SAGI-B/manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "/home/g####/.venvs/sa###/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
utility.execute()
File "/home/g####/.venvs/sa###/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 359, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/g####/.venvs/sa###/local/lib/python2.7/site-packages/django/core/management/base.py", line 294, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/g####/.venvs/sa###/local/lib/python2.7/site-packages/django/core/management/base.py", line 345, in execute
output = self.handle(*args, **options)
File "/home/g####/.venvs/sa###/local/lib/python2.7/site-packages/mod_wsgi/server/management/commands/runmodwsgi.py", line 71, in handle
fields = wsgi_application.split('.')
AttributeError: 'NoneType' object has no attribute 'split'
The Django version I use is 1.10.7 (I know, I should upgrade - I'm in the process). In the settings.py configuration file I didn't find the line with WSGI_APPLICATION = 'xyz.wsgi.application'. Could this be the cause of the error?
The absence of a line with WSGI_APPLICATION = ... in the settings.py file was the reason for the failure.
I'm trying to setup a Django project and am faced with the following error:
WARNINGS:
?: (rest_framework.W001) You have specified a default PAGE_SIZE pagination rest_framework setting,without specifying also a DEFAULT_PAGINATION_CLASS.
HINT: The default for DEFAULT_PAGINATION_CLASS is None. In previous versions this was PageNumberPagination. If you wish to define PAGE_SIZE globally whilst defining pagination_class on a per-view basis you may silence this check.
Traceback (most recent call last):
File "manage.py", line 18, in <module>
execute_from_command_line(sys.argv)
File "/Users/george/.virtualenvs/mixapi/lib/python3.7/site-packages/django/core/management/__init__.py", line 371, in execute_from_command_line
utility.execute()
File "/Users/george/.virtualenvs/mixapi/lib/python3.7/site-packages/django/core/management/__init__.py", line 365, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/george/.virtualenvs/mixapi/lib/python3.7/site-packages/django/core/management/base.py", line 288, in run_from_argv
self.execute(*args, **cmd_options)
File "/Users/george/.virtualenvs/mixapi/lib/python3.7/site-packages/django/core/management/base.py", line 335, in execute
output = self.handle(*args, **options)
File "/Users/george/.virtualenvs/mixapi/lib/python3.7/site-packages/django/core/management/commands/migrate.py", line 82, in handle
executor.loader.check_consistent_history(connection)
File "/Users/george/.virtualenvs/mixapi/lib/python3.7/site-packages/django/db/migrations/loader.py", line 291, in check_consistent_history
connection.alias,
django.db.migrations.exceptions.InconsistentMigrationHistory: Migration events.0001_initial is applied before its dependency commons.0001_initial on database 'default'.
make: *** [migrate] Error 1
I am running this from within a virtual environment, and have a docker-compose container for a postgres db running. Not sure how to start debugging this or why its happening. Any help would be appreciated
As per your snapshot:
you need to run command:- python manage.py migrate commons and then migrate for events model.
Follow these steps in your migrations folder inside the project:
Delete the pycache and the 0001_initial files.
Delete the db.sqlite3 from the root directory (be careful all your data will go away).
on the terminal run:
python manage.py makemigrations
python manage.py migrate
Note: don't forget to take a backup of your data.
For more detail, you can follow the link
I get this exception:
myproject#aptguettler:~$ manage.py migrate
Traceback (most recent call last):
File "/home/myproject/src/djangotools/djangotools/bin/manage.py", line 32, in <module>
main()
File "/home/myproject/src/djangotools/djangotools/bin/manage.py", line 29, in main
execute_from_command_line()
File "/home/myproject/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
utility.execute()
File "/home/myproject/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 359, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/myproject/local/lib/python2.7/site-packages/django/core/management/base.py", line 294, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/myproject/local/lib/python2.7/site-packages/django/core/management/base.py", line 345, in execute
output = self.handle(*args, **options)
File "/home/myproject/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 86, in handle
executor.loader.check_consistent_history(connection)
File "/home/myproject/local/lib/python2.7/site-packages/django/db/migrations/loader.py", line 292, in check_consistent_history
connection.alias,
django.db.migrations.exceptions.InconsistentMigrationHistory: Migration myapp.0029_bar is applied before its dependency myapp.0005_foo_squashed_0028_dynamic_year on database 'default'.
My migrations:
name
-------------------------------------------
0001_initial
0002_...
0003_...
0004_...
0005_foo
0006_...
0007_...
...
0028_dynamic_year
0029_bar
0030_...
What could be the reason?
I found the reason with the help of a team mate.
He did this:
squashed migrations
Production deployment and makemigrations
Deleted the squashed python files in the migration directory
I updated the git repo in my (old) develoment system. Then make migrations raised above exception.
Django can't solve this, since some migrations were applied and some not and the old squashed migration files are not available any more.
I took the most simple solution: I dropped my development database and created it from scratch.
I'm trying to develop and deploy django app on azure web apps.
While following the tutorial on azure website, after cloning the basic project to my local machine (using git) and creating the virtual environment, I'm trying to run the createsuperuser commend, and getting this error:
C:\Users\tutzy\Desktop\newtest\amir1>env\scripts\python manage.py createsuperuser
Traceback (most recent call last):
File "manage.py", line 17, in <module>
execute_from_command_line(sys.argv)
File "C:\Users\tutzy\Desktop\newtest\amir1\env\lib\site-packages\django\core\management\__init__.py", line 353, in execute_from_command_line
utility.execute()
File "C:\Users\tutzy\Desktop\newtest\amir1\env\lib\site-packages\django\core\management\__init__.py", line 345, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\tutzy\Desktop\newtest\amir1\env\lib\site-packages\django\core\management\base.py", line 348, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\tutzy\Desktop\newtest\amir1\env\lib\site-packages\django\contrib\auth\management\commands\createsuperuser.py", line 52, in execute
return super(Command, self).execute(*args, **options)
File "C:\Users\tutzy\Desktop\newtest\amir1\env\lib\site-packages\django\core\management\base.py", line 413, in execute
translation.activate(saved_locale)
File "C:\Users\tutzy\Desktop\newtest\amir1\env\lib\site-packages\django\utils\translation\__init__.py", line 154, in activate
return _trans.activate(language)
File "C:\Users\tutzy\Desktop\newtest\amir1\env\lib\site-packages\django\utils\translation\trans_real.py", line 216, in activate
_active.value = translation(language)
File "C:\Users\tutzy\Desktop\newtest\amir1\env\lib\site-packages\django\utils\translation\trans_real.py", line 205, in translation
_translations[language] = DjangoTranslation(language)
File "C:\Users\tutzy\Desktop\newtest\amir1\env\lib\site-packages\django\utils\translation\trans_real.py", line 118, in __init__
raise IOError("No translation files found for default language %s." % settings.LANGUAGE_CODE)
IOError: No translation files found for default language en-us.
It seems that your issue was similar with the other SO thread No translation file found for domain 'django' if you clone the Azure offical sample for Django like this. There is a *.mo line at the 49th line of .gitignore file. Please try to add the missing .mo file and do the createsupersuer operation again.
Hope it helps.