0

I want to remove django-taggit from my project, but when I removed the 'taggit' app from the INSTALLED_APPS, the following error occurred:

    raise NodeNotFoundError(self.error_message, self.key, origin=self.origin)
django.db.migrations.exceptions.NodeNotFoundError: Migration SourceManager.0002_auto_20190218_2112 dependencies reference nonexistent parent node ('taggit', '0002_auto_20150616_2121')

I think this error occurred because django-taggit has migration files, so how to safely remove it from my project?

adnanmuttaleb
  • 3,388
  • 1
  • 29
  • 46
  • 1
    I don't think there's an easy way, other than manually editing the older migration files to remove all references to taggit. If you do it correctly, it shouldn't cause any harm as long as you won't go back to any point where you need them to run correctly. – dirkgroten Mar 06 '19 at 19:42
  • Will this is bad news. – adnanmuttaleb Mar 06 '19 at 20:40

2 Answers2

1

You are half way through. The django-taggit has migration files and that's why you are facing the error.

You may want to reset the database state and re-apply the migrations to avoid this error.

This tutorial explains in detail how to reset the database and re-apply the migrations. I suggest you to follow the procedure step by step.

A word of caution: Even if you are a Unix bases OS user, avoid deleting migration files by executing the commands given in tutorial. The command messes up with Django default files and creates unncessary problems. Better to delete migration files one-by-one and model-by-model.

Abbas
  • 210
  • 2
  • 13
  • Thank you but I'm looking for a less aggressive solution. – adnanmuttaleb Mar 06 '19 at 20:40
  • 1
    Haven’t done it myself but here’s another suggestion: before removing taggit itself, squash your migrations. This will remove all references to taggit in the squashed migration. Make sure the squashed migration is applied to all databases you have. Then you can delete old migration files. And remove taggit. See [here](https://docs.djangoproject.com/en/2.1/topics/migrations/#squashing-migrations) for detailed instructions. – dirkgroten Mar 06 '19 at 21:59
  • @adnanmuttaleb: I'm afraid but there is no less aggressive solution to this. If you want to remove the dependency which is there in migrations, you have to take manual steps. It is not that aggressive anyway if you know what you are doing. – Abbas Mar 07 '19 at 06:41
0

This way works for me: First, I remove 'taggit' from INSTALLED_APPS, and then I remove everything inside folder migrations in my apps except the __init__.py file. I also deleted db.sqlite3 from my project.

Arjun
  • 11
  • 2
  • This does not really answer the question. If you have a different question, you can ask it by clicking [Ask Question](https://stackoverflow.com/questions/ask). To get notified when this question gets new answers, you can [follow this question](https://meta.stackexchange.com/q/345661). Once you have enough [reputation](https://stackoverflow.com/help/whats-reputation), you can also [add a bounty](https://stackoverflow.com/help/privileges/set-bounties) to draw more attention to this question. - [From Review](/review/late-answers/34625524) – Yogendra Jul 07 '23 at 08:32