Is there an approved method to completely remove an app?

Viewed 66

I have an app which was misconceived, and I would now like to delete it completely. I cannot find anything in the Django documentation about the right "blessed" way to do this.

I tried commenting out its models and running makemigrations but this threw errors because its views.py could not import them. If I removed its views from urls.py and tried, then makemigrations did not recognise that anything had changed.

Is it as simple as removing it from installed_apps in settings.py, removing its code, and manually deleting its one small model table from the DB? Or will the fact that it had an admin.py mean that there are dangling references left somewhere?

I'm using Django 2.2 if it makes any differerence

1 Answers

From experience:

  1. Remove any foreign key relations to this delete_app's models
  2. Make the migrations for those removals and apply
  3. Delete all the references to delete_app from other apps
  4. Delete all the code in delete_app except migrations
  5. Make the migrations for the deleted models and apply

After this I'm still left with delete_app's migrations and its entry in INSTALLED_APPS because other migrations from other apps still refer some dependency on delete_app's migrations. Haven't had time to check how I can remove it completely, or if there is a recommended way of doing this, but hope this helps.

Related