开发者

Database error : no such column: connect_connect.reciever_id

I have created following model

 class ConnectToFrom(models.Model):
    person = models.ForeignKey(User, null=True)
    kiosk = models.ForeignKey(Kiosks, null=True)

 class Connect(models.Model):
    parent_id = models.ForeignKey("self", null = True, blank = True)
    sender = models.ForeignKey(ConnectToFrom, related_name='sent_messages' )
    reciever = models.ForeignKey(ConnectToFrom, related_name='received_messages')
    .
    .
    .

I am not able to access Connects to add any connect object through admin site ! Can i not reference same model to two fields ? I am not able to figure out what exactly is causing the error . Please help

Traceback :

Environment:


Request Method: GET
Request URL: http://www.example.com:8000/admin/connect/connect/

Django Version: 1.3
Python Version: 2.6.6
Installed Applications:
['broadcast',
 'shastra',
 'fb_api',
 'log',
 'nties',
 'crc',
 'connect',
 'network',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.admin',
 'kiosks',
 'content',
 'home',
 'dashboard',
 'trial',
 'meta',
 'oembed']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware')


Traceback:
File "C:\Python26\lib\site-packages\django\core\handlers\base.py" in get_response
  111.                         response = callback(request, *callback_args, **callback_kwargs)
File "C:\Python26\lib\site-packages\django\contrib\admin\options.py" in wrapper
  307.                 return self.admin_site.admin_view(view)(*args, **kwargs)
File "C:\Python26\lib\site-packages\django\utils\decorators.py" in _wrapped_view
  93.                     response = view_func(request, *args, **kwargs)
File "C:\Python26\lib\site-packages\django\views\decorators\cache.py" in _wrapped_view_func
  79.         response = view_func(request, *args, **kwargs)
File "C:\Python26\lib\site-packages\django\contrib\admin\sites.py" in inner
  197.             return view(request, *args, **kwargs)
File "C:\Python26\lib\site-packages\django\utils\decorators.py" in _wrapper
  28.             return bound_func(*args, **kwargs)
File 开发者_开发技巧"C:\Python26\lib\site-packages\django\utils\decorators.py" in _wrapped_view
  93.                     response = view_func(request, *args, **kwargs)
File "C:\Python26\lib\site-packages\django\utils\decorators.py" in bound_func
  24.                 return func(self, *args2, **kwargs2)
File "C:\Python26\lib\site-packages\django\contrib\admin\options.py" in changelist_view
  1159.             'selection_note': _('0 of %(cnt)s selected') % {'cnt': len(cl.result_list)},
File "C:\Python26\lib\site-packages\django\db\models\query.py" in __len__
  82.                 self._result_cache = list(self.iterator())
File "C:\Python26\lib\site-packages\django\db\models\query.py" in iterator
  273.         for row in compiler.results_iter():
File "C:\Python26\lib\site-packages\django\db\models\sql\compiler.py" in results_iter
  680.         for rows in self.execute_sql(MULTI):
File "C:\Python26\lib\site-packages\django\db\models\sql\compiler.py" in execute_sql
  735.         cursor.execute(sql, params)
File "C:\Python26\lib\site-packages\django\db\backends\util.py" in execute
  34.             return self.cursor.execute(sql, params)
File "C:\Python26\lib\site-packages\django\db\backends\sqlite3\base.py" in execute
  234.             return Database.Cursor.execute(self, query, params)

Exception Type: DatabaseError at /admin/connect/connect/
Exception Value: no such column: connect_connect.reciever_id


Did you add the receiver field to your model after you initially created the connect_connect table? If so you'll have to manually add that field to your database (Django does not automatically sync changes to your models with your database.)

Just launch your interactive db shell, usually dbshell, and add the field. In MySQL it would be something like:

ALTER TABLE connect_connect ADD COLUMN receiver_id integer;

I'd recommend running manage.py sqlall appname to see how Django would create your db tables now, and then make sure the db matches that by making the necessary changes through your db shell.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜