Search code examples
djangodjango-migrationsdjango-1.9

How to drop a single model in Django, and leave the others


I have 4 models. I want to redo 1 one of them that I've been working on. The other 3 models have user data that I don't want to lose.

I want to entirely drop one table, and sync it up with what's in models.py.

How do I do this?


Solution

  • You could remove the model from models.py, and create a migration which will drop the table.

    ./manage.py makemigrations
    

    Then add the model back to your models.py, and create a new migration which will recreate the model.

    ./manage.py makemigrations
    

    Finally, run your migrations and you should be done.

    ./manage.py migrate