| 1 |
================================== |
| 2 |
How to delete a Django application |
| 3 |
================================== |
| 4 |
|
| 5 |
Django provides the ability to group sets of features into Python packages |
| 6 |
called :doc:`applications</ref/applications/>`. When requirements change, apps |
| 7 |
may become obsolete or unnecessary. The following steps will help you delete an |
| 8 |
application safely. |
| 9 |
|
| 10 |
#. Remove all references to the app (imports, foreign keys etc.). |
| 11 |
|
| 12 |
#. Remove all models from the corresponding ``models.py`` file. |
| 13 |
|
| 14 |
#. Create relevant migrations by running :djadmin:`makemigrations`. This step |
| 15 |
generates a migration that deletes tables for the removed models, and any |
| 16 |
other required migration for updating relationships connected to those |
| 17 |
models. |
| 18 |
|
| 19 |
#. :ref:`Squash <migration-squashing>` out references to the app in other apps' |
| 20 |
migrations. |
| 21 |
|
| 22 |
#. Apply migrations locally, runs tests, and verify the correctness of your |
| 23 |
project. |
| 24 |
|
| 25 |
#. Deploy/release your updated Django project. |
| 26 |
|
| 27 |
#. Remove the app from :setting:`INSTALLED_APPS`. |
| 28 |
|
| 29 |
#. Finally, remove the app's directory. |