DEV Community

Cover image for How to Delete a Table from a Database in Django
tieje
tieje

Posted on

How to Delete a Table from a Database in Django

Solution Link

Solution

How to delete a single table in Django 4.0:

  1. Remove <YourDeleteTable> model from models.py file
  2. Remove <YourDeleteTable> class from admin.py file and ALL other instances of wherever this class is used.
  3. python manage.py makemigrations <<your app>>
  4. python manage.py migrate

Background

I wrote this guide because I lost all my data from following a different guide on Stack Overflow. T_T

Solutions to Additional Database Problems in Django

Discussion (2)

Collapse
sloan profile image
Sloan

Hi there, we encourage authors to share their entire posts here on DEV, rather than mostly pointing to an external link. Doing so helps ensure that readers don’t have to jump around to too many different pages, and it helps focus the conversation right here in the comments section.

If you choose to do so, you also have the option to add a canonical URL directly to your post.

Collapse
tieje profile image
tieje Author

Will do