customize askbot
Hi,
I want to add more table to the askbot database. Usually, in Django, we can make new file in models.py (or create new file in folder model). Then run manage.py syncdb. But, I cannot do that in askbot. What am I missing?
my file is name subject.py in models
import re from django.db import models from django.db import connection, transaction from django.contrib.auth.models import User from django.utils.translation import ugettext as _ from askbot.models.base import DeletableContent from askbot.models.base import BaseQuerySetManager from askbot import const
class Subject(models.Model): subject = models.CharField(max_length=64)
class Meta:
app_label='askbot'
db_table = u'subject'
def __unicode__(self):
return self.subject
I have used from askbot.models.subject import Subject in __init__.py in folder models.
Thanks.
Comments
I've seen this issue before and don't know the answer. This issue is present in some models files but not others.. Try adding your model to a new .py file within the models module or a different file.
Someone just suggested to me that you add that model to
__all__
list in theaskbot/models/__init__.py
, please see if that helps.There is no Subject table yet. Should I add the table first and then create the models? Since I am new to Django and Python, I am not sure if my file subject.py is correct ... I saw that this file can be compiled and create the file subject.pyc
No, syncdb should create a table for you, at the bottom of
askbot/models/__init__.py
there is a list__all__
- add your model there as well.I did this by adding a separate directory below manage.py (after laboriously moving askbot to that level), and adding a models.py there. It worked. Askbot's install script makes this all a bit harder though.