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.

To enter a block of code:

  • enter empty line after your previous text
  • paste or type the code
  • select the code and press the button above
Preview: (hide)
A little girl's avatar
1
A little girl
asked 13 years ago

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 (13 years ago)

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 (13 years ago)

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 (13 years ago)

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 (13 years ago)

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 (13 years ago)
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.

To enter a block of code:

  • enter empty line after your previous text
  • paste or type the code
  • select the code and press the button above
Preview: (hide)
ajk14's avatar
1
ajk14
answered 13 years ago
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 (13 years ago)
see more comments