views:

22

answers:

2

With what command can i delete tables from a django db of a specific app/ only one table? I did find all sorts of things, but not how to get rid of a table.

Also while I am at this.

I create the models and hit syncdb and then I have the tables. If I want to update/add to those tables, do I run into problems?

Thanks!

A: 

If you are deleting a table, this is done in the model file of the specific app that you are trying to delete, there is no command for this, you just go into the file and delete it and then re-run syncdb, for your other question, the answer is the same.. every app folder should have a file called "models.py" and here is where the models which are, in this case, equivalent to tables are specified, along with their fields, you simply edit this to make any changes.

Rick
ApPeL's answer gave me a new perspective on why you might be doing this, I am guessing you are trying to sync an existing DB with a django install? Anyways, once you are working in that Django install you should always create new models / tables through Django as it will do this for you (automatically creating the DB tables), but I supposed it doesn't delete the table when you delete the model? If so, ApPel's solution would be correct as it just needs a script that goes into your database to sync it up
Rick
I can exactly tell you why I am doing this. I am working only in django. And I am trying to get a rather complex db going. So right now I am trying out different variations of that. To avoid having a messed up db I want to delete. Also. I wanted to know that, in case later when I am up and running I want to delete specific tables, I would like to know if that is possibile and how.
MacPython
A: 

Your best bet would be to get django-south installed in your machine.

if you are using pip, do pip install django-south

This allows you too migrate data forward and backwards.

This is very handy especially if you need to update tables, and new tables etc.

check it out.

adding south to apps are as easy as python manage.py schemamigration appname --initial

Make your changes in a model and run the following python manage.py schemamigration appname --auto

Once your data migration file has been created it'll tell you data is now ready to migrate.

Simply use python manage.py migrate appname

http://south.aeracode.org/docs/about.html

Hope this helps

ApPeL
Cool. Thanks! Heard about that. Is pip build in or do I have to get that?
MacPython
pip does not come standard, but easy install does.run the following in terminal, easy_install pip
ApPeL
if it is not too much to ask, could you maybe upvote as well.
ApPeL