First time here? Check out the FAQ!
0

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.

A little girl's avatar
1
A little girl
asked 2012-01-25 06:00:35 -0500
edit flag offensive 0 remove flag 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's avatar Evgeny (2012-01-25 06:14:18 -0500) 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's avatar Evgeny (2012-01-25 06:20:06 -0500) 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's avatar A little girl (2012-01-25 09:02:46 -0500) 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's avatar Evgeny (2012-01-25 09:05:12 -0500) 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's avatar brycenesbitt (2012-01-27 15:56:45 -0500) edit
add a comment see more comments

1 Answer

0

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.

ajk14's avatar
1
ajk14
answered 2012-02-27 13:20:03 -0500
edit flag offensive 0 remove flag delete link

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's avatar Evgeny (2012-02-27 13:34:05 -0500) edit
add a comment see more comments