Ask Your Question

How can I modify models in askbot?

asked 2011-10-26 03:34:03 -0600

iicore's avatar

updated 2011-10-26 03:56:29 -0600

If I want to add a new element in Class Question(, What should I do?

I have modify askbot/models/ like this:

 title    = models.CharField(max_length=300)
 tags     = models.ManyToManyField('Tag', related_name='questions')
 answer_accepted = models.BooleanField(default=False)
 +testestest = models.BooleanField(default=False)
 closed          = models.BooleanField(default=False)

After modify, I delete old database in mysql, run "python syncdb; python migrate". Then I check the question table in mysql again, but "testestest" field isn't exist in question table.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2011-10-26 09:02:33 -0600

Evgeny's avatar

updated 2011-10-26 09:03:39 -0600

Hello, in this case it will be necessary to use South migrations.

Here is the documentation

First thing, after you change code in the models, make a schema migration:

python schemamigration askbot --auto

Then apply the migration.

python migrate askbot

All migrations for askbot live in the directory askbot/migrations - you will need to edit your migration and the subsequent askbot's migration (when we make a new one)

The edit in the migration files is necessary to specify that your migration must run after the last current askbot's migration, and the next askbot's migration must run after yours.

Here is the document explaining how to deal with migration dependencies

South has two types of migrations - schema migrations and data migrations. Schema migrations change the database schema, while data migrations only modify the data.

At Askbot we love South - cheers to the South devs! Definitely check out their django & python hosting service called it make django deployments real easy.

edit flag offensive delete link more

answered 2011-10-27 02:52:08 -0600

iicore's avatar

Thanks, Evgeny, it works!!!

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2011-10-26 03:34:03 -0600

Seen: 337 times

Last updated: Oct 27 '11