Ask Your Question
0

customize askbot

asked 2012-01-25 06:00:35 -0600

A little girl gravatar image

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.

edit retag flag offensive close merge delete

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.

Evgeny gravatar imageEvgeny ( 2012-01-25 06:14:18 -0600 )edit

Someone just suggested to me that you add that model to __all__ list in the askbot/models/__init__.py, please see if that helps.

Evgeny gravatar imageEvgeny ( 2012-01-25 06:20:06 -0600 )edit

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

A little girl gravatar imageA little girl ( 2012-01-25 09:02:46 -0600 )edit

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.

Evgeny gravatar imageEvgeny ( 2012-01-25 09:05:12 -0600 )edit

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.

brycenesbitt gravatar imagebrycenesbitt ( 2012-01-27 15:56:45 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2012-02-27 13:20:03 -0600

ajk14 gravatar image

Has this question been resolved? I'm having the exact same problem, where syncdb is not creating the new table that I am expecting.

I've added my model to the __all__ list in models/__init__.py but that doesn't seem to have helped.

edit flag offensive delete link more

Comments

I don't know what is the issue here, sorry don't have the time to look into this. For you it will be better if you keep your additional code outside of askbot tree, because upgrading askbot code will be easier that way. Try to couple your code to askbot as loosely as possible, it's a better approach, generally speaking.

Evgeny gravatar imageEvgeny ( 2012-02-27 13:34:05 -0600 )edit

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

Stats

Asked: 2012-01-25 06:00:35 -0600

Seen: 392 times

Last updated: Feb 27 '12