Ask Your Question
0

Creating a Table in Askbot Database

asked 2012-02-28 22:01:27 -0500

ajk14 gravatar image ajk14
1 1

I'm trying to add a new table to the askbot database by adding the following code to the file models/questions.py

class Foo(models.Model):
    foo = models.CharField(max_length=100)

However, when I run syncdb, this table 'Foo' is not created. I've tried dropping the database and starting with a fresh database, and I've also updated my migrations using 'python manage.py schemamigration askbot --auto' command. I get the same problem whether I put my new model inside an existing .py file or inside a new one, and it even occurs when I create an entirely new Django app and place the model code there.

I'm using PostgreSQL 8.4.8 and Django 1.3.1. I've seen this problem discussed on here before, but has anyone actually solved this problem?

delete close flag offensive retag edit

1 Answer

Sort by » oldest newest most voted
0

answered 2012-03-02 16:00:51 -0500

Evgeny gravatar image Evgeny flag of Chile
11314 50 84 183
http://askbot.org/

Apparently django works this way. In order to add a model when the models module three things need to be done:

  • it has to be imported in askbot/models/__init__.py - e.g. from askbot.models.question import Foo
  • it has to be added to the __all__ list (if used, in askbot - it is) inside askbot/models/__init__.py
  • in the Meta subclass of your model Foo you must add app_label = 'askbot'

Coming back to your intention. It is a lot better to create an outside application and keep the extra functionality loosely coupled with askbot - which is a "third party" code to you.

If you decide to go down the path of hacking the third party code - later on it might be a lot harder for you to maintain your work and keep up with the upgrades of say askbot.

If there is something in askbot that prevents you from easily adding functionalities via external apps - please do let us know.

link publish delete flag offensive edit

Your answer

Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Reliable Askbot Hosting

Create your Q&A site at askbot.com. Managed Askbot hosting at just $15/mo. Dedicated hosting, support contracts, consulting services.

create your Q&A site
30 days free trial

Question tools

Follow

subscribe to rss feed

Stats

Asked: 2012-02-28 22:01:27 -0500

Seen: 113 times

Last updated: Mar 02 '12