Ask Your Question

ManyToMany join table "question_followed_by" is empty.

asked 2011-08-17 03:32:50 -0600

Alex Dong gravatar image

We are integrating askbot into our existing django site. We found the join table question_followed_by is empty even when we have created 9 questions.

mysql> describe question_followed_by;
| Field       | Type    | Null | Key | Default | Extra          |
| id          | int(11) | NO   | PRI | NULL    | auto_increment |
| question_id | int(11) | NO   | MUL | NULL    |                |
| user_id     | int(11) | NO   | MUL | NULL    |                |
3 rows in set (0.00 sec)

mysql> select * from question_followed_by;
Empty set (0.00 sec)

mysql> select count(*) from question;
| count(*) |
|        9 |
1 row in set (0.00 sec)

I'm wondering what would cause the join table to miss records?

Thanks a lot,


edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2011-08-17 04:07:26 -0600

Alex Dong gravatar image

Hi Evgeny,

Thanks for the quick reply. Yes, you are right, it's because no one is following the question yet. However, I am wondering why would I get this exception?

The site runs perfectly with django's " runserver". However, when we deployed it onto our staging server, which uses mod_wsgi, we're getting "Cannot resolve keyword 'followed_questions' into field" error.

Here is the error message and call stack. You can see that the ForeignKey and ManyToManyField in Question model are both missing in the list:

FieldError at /askbot/question/9/where-to-go-for-lunch Cannot resolve keyword 'followed_questions' into field. Choices are: _message_set, about, bronze, comment_comments, comment_flags, consecutive_days_visit_count, country, date_joined, date_of_birth, display_tag_filter_strategy, email, email_isvalid, email_key, email_tag_filter_strategy, first_name, gold, gravatar, groups, has_custom_avatar, id, ignored_tags, interesting_tags, is_active, is_staff, is_superuser, last_login, last_name, last_seen, location, logentry, new_response_count, password, questions_per_page, real_name, reputation, seen_response_count, show_country, silver, status, user_permissions, username, userprofile, websiteuserprofile, website

Here is the call stack:

/usr/local/lib/python2.6/dist-packages/django/core/handlers/ in get_response
/usr/local/lib/python2.6/dist-packages/django/utils/ in _wrapped_view
/var/www/askbot/hpsport/askbot/views/ in question
/var/www/askbot/hpsport/askbot/ in __init__
/usr/local/lib/python2.6/dist-packages/django/db/models/ in all
/usr/local/lib/python2.6/dist-packages/django/db/models/fields/ in get_query_set
/usr/local/lib/python2.6/dist-packages/django/db/models/ in filter
/usr/local/lib/python2.6/dist-packages/django/db/models/ in _filter_or_exclude
/usr/local/lib/python2.6/dist-packages/django/db/models/sql/ in add_q
/usr/local/lib/python2.6/dist-packages/django/db/models/sql/ in add_filter
/usr/local/lib/python2.6/dist-packages/django/db/models/sql/ in setup_joins
edit flag offensive delete link more


Sounds like your python environment is different when you run under mod_wsgi. Probably python paths are not set the same way. Please take a look at mod_wsgi wiki for deployment under apache.
Evgeny gravatar imageEvgeny ( 2011-08-17 04:13:44 -0600 )edit
Evgeny, that's exactly what we've suspected. However, the mod_wsgi's PYTHONPATH all look quite innocent. Since askbot monkey patched django's User object, will it be possible that it causes some problem similar to the one described here: This is the django ticket associated with it:
Alex Dong gravatar imageAlex Dong ( 2011-08-17 04:30:53 -0600 )edit
I have pinpointed the problem to be askbot/ L644 the AnswerForm uses "question.followed_by.all()" to see whether it should set the default checkbox to be true or false. The "question.followed_by" statement is causing the above problem. Considering the fact that all other functions are working perfectly well, I do not think there are any major mod_wsgi setting errors. @Evgeny, how likely do you think it's the monkey-patching that's causing this problem?
Alex Dong gravatar imageAlex Dong ( 2011-08-17 04:53:08 -0600 )edit

answered 2011-08-17 03:49:23 -0600

Evgeny gravatar image

Maybe because nobody follows questions yet? Click follow button on a question and check the table again.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2011-08-17 03:32:50 -0600

Seen: 216 times

Last updated: Aug 17 '11