How to Remove an App from Django Project

How to correctly remove a Model or an App in Django

Advert

Removing a django app is easy, remove all imports and usage of the app and also from INSTALLED_APPS section in settings.py.

That does remove the app from the project, but not the files and the apps history from the project. The app files will still be in the project and the database will exist in the DB, unless you clone the code to a new machine and migrate, because the migrations of the removed app won't be consider since is removed from settings.py.

So removing a Django app involves these steps:

  • Remove all imports and usage of the app in the project.
  • Remove all models in models.py of the app. Can bring in error if the models are called in other files of the app like admin.py or any other so remove the reference or just delete the files expect __init__.py and models.py.
  • Create a new migration for the app, which removes all models.
  • Perform Migration.
  • Production : If this is to be done in production, perform tests, push the code to production and perform migration before you proceed to next step.
  • Remove the app from INSTALLED_APPS in settings.py.
  • Delete the directory.

This removes the app database and also files, but make sure to remove any packages you used by the app which is not required in project and update the other documentation.

If you have deleted the files before performing the remove migrations, you can drop tables from project database manually depending on your database.

Comments

Wow ! you have someting to tell us. That's great! Please keep in mind that comments are moderated, we employ rel="nofollow" for links, avoid using a spammy word or a domain in name field, it might end up as a Spam. Thanks for reading.

Last 5 Articles

All Articles >

  1. 4 Ways to Increase Conversion Rates using Videos

     
  2. Getting the best customer experience analytics solutions

     
  3. How to Remove an App from Django Project

     
  4. Parse Time HH:mm:ss without date in javascript

     
  5. Software Testing

     

News Letter

Subscribe to our email newsletter for useful tips and valuable resources, sent out every new article release.