I wrote python script for dropping tables in all Django apps. (using settings.INSTALLED_APP)
https://gist.github.com/1520683
My django project creates 41 tables after running manage.py syncdb, but my script says only 40 tables will be dropped. So, I examined the result of sqlall and result of sqlclear. And I revealed sqlclear omits one table that stores ManyToManyField relationship.
I knew that drop database is much simpler than the above script. But I confused why django admin or manage script omit some tables while running sql commands.
Below model creates common_userbook_purchasedBooks table while running syncdb, but not in sqlclear command.
class UserBook(models.Model):
user = models.OneToOneField(User)
purchasedBooks = models.ManyToManyField(Book)
Added) So, I’m using an alternative approach for this.
https://gist.github.com/1520810
lqez, I gues this issue related to you local environment, because for Django 1.3.1, Python 2.7.2
for models
when I run
(.env)testme$ ./manage.py sqlclear testappoutput looks likesqlite3
postgresql_psycopg2
mysql
Also your script can be a little bit improved using
introspection: