Benjamin Bakhshi
Benjamin Bakhshi

Reputation: 663

How to update SQLite3 database after adding object to a Class?

I just added the num object, and tried adding it to my admin, but I get the following error: Exception Value:
no such column: game_riddle.num

Here is the class:

class Riddle(models.Model):
"""represents a riddle, comprising a question and hints"""
world = models.ForeignKey(World)
question = models.TextField()
num = models.IntegerField()

I have a small database and the last time I added the object I had to run:sqlclear and then syncdb

How can I fix my bug without clearing the database?

Upvotes: 0

Views: 77

Answers (2)

catherine
catherine

Reputation: 22808

  1. Read this documention: http://south.readthedocs.org/en/0.7.6/installation.html

  2. easy_install South

  3. After install, put 'south' in your installed_app in settings

  4. Don't forget to sync: python manage.py syncdb

  5. Run this command: python manage.py schemamigration app_name --auto

  6. The migrate: python manage.py migrate

That's it. Next if you add new model or have changes. Just do step 5 and 6 and your model will be updated.

Upvotes: 2

Udi
Udi

Reputation: 30522

You will need to use a migration tool such as South:

South brings migrations to Django applications. Its main objectives are to provide a simple, stable and database-independent migration layer to prevent all the hassle schema changes over time bring to your Django applications.

Upvotes: 1

Related Questions