How to remove models from django?
In Django how do you remove models that you have synced into the database?
For example in Django tutorial page had this following code
from django.db import models class Poll(models.Model): question = models.CharField(max_length=200) pub_date = models.DateTimeField('date published') class Choice(models.Model): poll = models.ForeignKey(Poll) choice = models.CharField(max_length=200) votes = models.IntegerField()
Then I used
python manage.py sql polls and
python manage.py sql choice to create the tables into the database. But what if I did something wrong and don’t want that model any more. What’s the syntax to remove it?
There is no syntax. Django doesn’t removes tables or columns. You have to manually change your database or use a migration tool like South.
If you justing playing around with tutorial the easier way is to delete your sqlite database file and run a sync again.
Answered By – Cesar Canassa