tags:

views:

38

answers:

2

What is the procedure for completely uninstalling a Django app, complete with database removal?

A: 

django app is a "set" of *.py files and a directory with a django-app-name. So you can simply delete the whole folder with all *.py files

To "remove" tables from DB you should use DELETE FROM <app-name_table-names>

Furthermore, you have to delete lines witgh app-name from setting.py in a root directory

V-Light
Assuming you aren't sharing the database with another app you can just drop the db named in settings.py.
joel3000
each app has own db - not bad
V-Light
+6  A: 
  1. Django has a handy management command that will give you the necessary SQL to drop all the tables for an app. See the sqlclear docs for more information. Basically, running ./manage.py sqlclear my_app_name you'll get the SQL statements that should be executed to get rid of all traces of the app in your DB. You still need to copy and paste (or pipe) those statements into your SQL client.

  2. To remove the app from your project, all you need to do is remove it from INSTALLED_APPS in your project's settings.py. Django will no longer load the app.

  3. If you no longer want the app's files hanging around, delete the app directory from your project directory or other location on your PYTHONPATH where it resides.

  4. (optional) If the app stored media files, cache files, or other temporary files somewhere, you may want to delete those as well. Also be wary of lingering session data that might be leftover from the app.

Gabriel Hurley
+1 - you covered it all.
Yuval A
Excellent answer, just one addition that I'd make: pip uninstall package-name is your friend, much nicer than trawling around your PYTHONPATH.
Daveyjoe