-1

I am working on a project on Django and I am facing an issue with it. I have done some migration wrong and decided to delete them from the project folder and rebuilt them. Since I did that Django is acting "like deleted one of its source files". The error occurs on every project I try to migrate, makemigration, runserver. I tried to reinstall django with pip but it does not help at all. I also delete the .pyc files but it did not help at all. I even generated new project but still ran on the same issue. I do think that is helpful but I have to mention that shell launches OK.

The error

Performing system checks...

System check identified no issues (0 silenced).
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x1049a38c8>
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/django/utils/autoreload.py", line 225, in wrapper
    fn(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 123, in inner_run
    self.check_migrations()
  File "/usr/local/lib/python3.6/site-packages/django/core/management/base.py", line 427, in check_migrations
    executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
  File "/usr/local/lib/python3.6/site-packages/django/db/migrations/executor.py", line 18, in __init__
    self.loader = MigrationLoader(self.connection)
  File "/usr/local/lib/python3.6/site-packages/django/db/migrations/loader.py", line 49, in __init__
    self.build_graph()
  File "/usr/local/lib/python3.6/site-packages/django/db/migrations/loader.py", line 267, in build_graph
    raise exc
  File "/usr/local/lib/python3.6/site-packages/django/db/migrations/loader.py", line 241, in build_graph
    self.graph.validate_consistency()
  File "/usr/local/lib/python3.6/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 "/usr/local/lib/python3.6/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 "/usr/local/lib/python3.6/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 admin.0003_auto_20180326_1230 dependencies reference nonexistent parent node ('profile', '0003_auto_20180326_1230')

It is acting very weird and I still can't understand what might have caused the issue.

Update

Using virtualenv I managed to get it working. I set up virtualenv with python3 and I just ran makemigrationsand it worked like nothing had ever happened. So I guess it is something wrong with the source files. On the other hand I still can't find what is causing the issue.

dstrants
  • 7,423
  • 2
  • 19
  • 27
  • 1
    This is a inconsistent migrations problem. Check this one https://stackoverflow.com/questions/44651760/django-db-migrations-exceptions-inconsistentmigrationhistory/44651902#44651902. Also django's installation has nothing to do with this. The error is because of your mistake. – Arpit Solanki Mar 26 '18 at 11:03
  • Yeah, it seems very logical to is my mistake but does Django fails on every project? – dstrants Mar 26 '18 at 11:05
  • No it does not fail. Check out the link mentioned in my comment, read that question and answers carefully. If you still face problem then comment. – Arpit Solanki Mar 26 '18 at 11:07
  • I tried every solution proposed in the question you mentioned but nothing worked. The same error coming up again and again... I even deleted the database. With no migration files and `makemigrations` fails – dstrants Mar 26 '18 at 11:45

1 Answers1

1

The migration admin.0003_auto_20180326_1230 depends on profile.0003_auto_20180326_1230.

As you deleted profile.0003_auto_20180326_1230, you should look at admin.0003_auto_20180326_1230 to see if you can modify or remove it.

admin.0003_auto_20180326_1230 should be in admin/migrations/0003_auto_20180326_1230.py

Update

The use of virtualenv with Django is recommended. doc

I personally use Pipenv to manage my virtualenvs.

Django must have been mixing the migrations from differents projects as they weren't isolated by virtualenvs. Maybe it couldn't find the right settings module or something.

Dodge
  • 3,219
  • 3
  • 19
  • 38
logut
  • 23
  • 6
  • 1
    Actually, this is what I thought also, but the same issue occurs in totally irrelevant projects, plus I have no admin directory in my project. I cannot locate the file causing the issue anywhere on my computer. – dstrants Mar 26 '18 at 15:29
  • Yea I know :|, I had set it up but forgot to activate it. This must be the issue. Any ideas on how to fix those conflicts? I think it may be the python cache files in the django directory. – dstrants Mar 29 '18 at 07:06