Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

newbie difficulty using south with pycharm - DatabaseError: no such table: south_migrationhistory

I'm using sqlite3 and pycharm to learn more about django, and googled to find that south is recommended to make it easier to modify models after they have been created.

I'm trying to follow the advice on http://south.aeracode.org/docs/tutorial/part1.html#starting-off.

The most success I've had so far is to create a simple model and run syncdb before adding south to installed_apps. That way the intial tables are created and I get a chance to create a super user. (Django admin seems to fret if there are no users).

Then I add south to installed_apps, and run django_manage.py schemamigration bookmarks --initial

It seems to work fine. A new directory is created called migrations with a couple of files in it in my app folder and an encouraging message. "Created 0001_initial.py. You can now apply this migration with: ./manage.py migrate bookmarks"

The next step - django_manage.py" migrate bookmarks generates the following error message django.db.utils.DatabaseError: no such table: south_migrationhistory.

I thought that table would be created in the first schememigration step. What am I missing? Can anyone help?

Marg

like image 982
Marg Avatar asked Feb 26 '12 13:02

Marg


2 Answers

South uses a table if its own to keep track of which migrations have been applied. Before you can apply any migrations, this must have been created, using python ./manage.py syncdb.

As well as for setting up south, you will find syncdb sometimes necessary for non-south apps in your project, such as the very common django.contrib.auth.

Note that as a convenience, you can run both in one go like this

python ./manage.py syncdb --migrate
like image 196
kdt Avatar answered Sep 28 '22 19:09

kdt


My latest (unsuccessful) effort was the following

  1. Create application – synch db – superuser created
  2. Test run –admin screen shows basic tables
  3. Add south, and syncdb from command line with manage.py syncdb – south_migrationhistory table created. Add basic vanilla model
  4. Tried various combinations of manage.py syncdb –manage, and schemamigration from Pycharm (if run from within pycharm a migrations directory is created within the app – if run from the command line the directory does not seem to be created.)
  5. Django admin screen shows table – but if I try to edit the table it says that it doesn’t exist
  6. Check database structure using SQLite browser - table for newly created model doesn’t exist

I’m starting to think that the whole thing is not worth the time wasting hassle – maybe I’m better off just modifying the tables in SQLite browser

like image 36
Marg Avatar answered Sep 28 '22 18:09

Marg