2012-03-06 194 views
2

我正在測試django-userena演示項目。我已經安裝了sendmail。爲什麼我看到這個錯誤

我看到這個錯誤,當我註冊:

Environment: 


Request Method: POST 
Request URL: http://127.0.0.1:8000/accounts/signup/ 

Django Version: 1.3.1 
Python Version: 2.7.2 
Installed Applications: 
['django.contrib.auth', 
'django.contrib.contenttypes', 
'django.contrib.sessions', 
'django.contrib.sites', 
'django.contrib.messages', 
'django.contrib.admin', 
'easy_thumbnails', 
'guardian', 
'south', 
'userena', 
'userena.contrib.umessages', 
'demo_project.profiles'] 
Installed Middleware: 
('django.middleware.common.CommonMiddleware', 
'django.contrib.sessions.middleware.SessionMiddleware', 
'django.middleware.locale.LocaleMiddleware', 
'django.middleware.csrf.CsrfViewMiddleware', 
'django.contrib.auth.middleware.AuthenticationMiddleware', 
'django.contrib.messages.middleware.MessageMiddleware', 
'userena.middleware.UserenaLocaleMiddleware') 


Traceback: 
File "/home/elie/.django-projects/showpill/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response 
    111.       response = callback(request, *callback_args, **callback_kwargs) 
File "/home/elie/.django-projects/showpill/local/lib/python2.7/site-packages/userena/decorators.py" in _wrapped_view 
    28.   return view_func(request, *args, **kwargs) 
File "/home/elie/.django-projects/showpill/local/lib/python2.7/site-packages/userena/views.py" in signup 
    69.   if form.is_valid(): 
File "/home/elie/.django-projects/showpill/local/lib/python2.7/site-packages/django/forms/forms.py" in is_valid 
    121.   return self.is_bound and not bool(self.errors) 
File "/home/elie/.django-projects/showpill/local/lib/python2.7/site-packages/django/forms/forms.py" in _get_errors 
    112.    self.full_clean() 
File "/home/elie/.django-projects/showpill/local/lib/python2.7/site-packages/django/forms/forms.py" in full_clean 
    267.   self._clean_fields() 
File "/home/elie/.django-projects/showpill/local/lib/python2.7/site-packages/django/forms/forms.py" in _clean_fields 
    287.      value = getattr(self, 'clean_%s' % name)() 
File "/home/elie/.django-projects/showpill/local/lib/python2.7/site-packages/userena/forms.py" in clean_username 
    49.    user = User.objects.get(username__iexact=self.cleaned_data['username']) 
File "/home/elie/.django-projects/showpill/local/lib/python2.7/site-packages/django/db/models/manager.py" in get 
    132.   return self.get_query_set().get(*args, **kwargs) 
File "/home/elie/.django-projects/showpill/local/lib/python2.7/site-packages/django/db/models/query.py" in get 
    344.   num = len(clone) 
File "/home/elie/.django-projects/showpill/local/lib/python2.7/site-packages/django/db/models/query.py" in __len__ 
    82.     self._result_cache = list(self.iterator()) 
File "/home/elie/.django-projects/showpill/local/lib/python2.7/site-packages/django/db/models/query.py" in iterator 
    273.   for row in compiler.results_iter(): 
File "/home/elie/.django-projects/showpill/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py" in results_iter 
    680.   for rows in self.execute_sql(MULTI): 
File "/home/elie/.django-projects/showpill/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py" in execute_sql 
    735.   cursor.execute(sql, params) 
File "/home/elie/.django-projects/showpill/local/lib/python2.7/site-packages/django/db/backends/util.py" in execute 
    34.    return self.cursor.execute(sql, params) 
File "/home/elie/.django-projects/showpill/local/lib/python2.7/site-packages/django/db/backends/mysql/base.py" in execute 
    86.    return self.cursor.execute(query, args) 
File "/home/elie/.django-projects/showpill/local/lib/python2.7/site-packages/MySQLdb/cursors.py" in execute 
    174.    self.errorhandler(self, exc, value) 
File "/home/elie/.django-projects/showpill/local/lib/python2.7/site-packages/MySQLdb/connections.py" in defaulterrorhandler 
    36.  raise errorclass, errorvalue 

Exception Type: DatabaseError at /accounts/signup/ 
Exception Value: (1146, "Table 'demo_project.auth_user' doesn't exist") 

編輯

抱歉,我不能較早的更新這個問題,我是這麼忙,當我運行執行syncdb,我看到這個錯誤

Environment: 


Request Method: POST 
Request URL: http://127.0.0.1:8000/accounts/signup/ 

Django Version: 1.3.1 
Python Version: 2.7.2 
Installed Applications: 
['django.contrib.auth', 
'django.contrib.contenttypes', 
'django.contrib.sessions', 
'django.contrib.sites', 
'django.contrib.messages', 
'django.contrib.admin', 
'easy_thumbnails', 
'guardian', 
'south', 
'userena', 
'userena.contrib.umessages', 
'demo_project.profiles'] 
Installed Middleware: 
('django.middleware.common.CommonMiddleware', 
'django.contrib.sessions.middleware.SessionMiddleware', 
'django.middleware.locale.LocaleMiddleware', 
'django.middleware.csrf.CsrfViewMiddleware', 
'django.contrib.auth.middleware.AuthenticationMiddleware', 
'django.contrib.messages.middleware.MessageMiddleware', 
'userena.middleware.UserenaLocaleMiddleware') 


Traceback: 
File "/home/elie/.django-projects/showpill/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response 
    111.       response = callback(request, *callback_args, **callback_kwargs) 
File "/home/elie/.django-projects/showpill/local/lib/python2.7/site-packages/userena/decorators.py" in _wrapped_view 
    28.   return view_func(request, *args, **kwargs) 
File "/home/elie/.django-projects/showpill/local/lib/python2.7/site-packages/userena/views.py" in signup 
    70.    user = form.save() 
File "/home/elie/.django-projects/showpill/local/lib/python2.7/site-packages/userena/forms.py" in save 
    86.              userena_settings.USERENA_ACTIVATION_REQUIRED) 
File "/home/elie/.django-projects/showpill/local/lib/python2.7/site-packages/userena/managers.py" in create_user 
    62.   userena_profile = self.create_userena_profile(new_user) 
File "/home/elie/.django-projects/showpill/local/lib/python2.7/site-packages/userena/managers.py" in create_userena_profile 
    104.       activation_key=activation_key) 
File "/home/elie/.django-projects/showpill/local/lib/python2.7/site-packages/django/db/models/manager.py" in create 
    138.   return self.get_query_set().create(**kwargs) 
File "/home/elie/.django-projects/showpill/local/lib/python2.7/site-packages/django/db/models/query.py" in create 
    360.   obj.save(force_insert=True, using=self.db) 
File "/home/elie/.django-projects/showpill/local/lib/python2.7/site-packages/django/db/models/base.py" in save 
    460.   self.save_base(using=using, force_insert=force_insert, force_update=force_update) 
File "/home/elie/.django-projects/showpill/local/lib/python2.7/site-packages/django/db/models/base.py" in save_base 
    553.      result = manager._insert(values, return_id=update_pk, using=using) 
File "/home/elie/.django-projects/showpill/local/lib/python2.7/site-packages/django/db/models/manager.py" in _insert 
    195.   return insert_query(self.model, values, **kwargs) 
File "/home/elie/.django-projects/showpill/local/lib/python2.7/site-packages/django/db/models/query.py" in insert_query 
    1436.  return query.get_compiler(using=using).execute_sql(return_id) 
File "/home/elie/.django-projects/showpill/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py" in execute_sql 
    791.   cursor = super(SQLInsertCompiler, self).execute_sql(None) 
File "/home/elie/.django-projects/showpill/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py" in execute_sql 
    735.   cursor.execute(sql, params) 
File "/home/elie/.django-projects/showpill/local/lib/python2.7/site-packages/django/db/backends/util.py" in execute 
    34.    return self.cursor.execute(sql, params) 
File "/home/elie/.django-projects/showpill/local/lib/python2.7/site-packages/django/db/backends/mysql/base.py" in execute 
    86.    return self.cursor.execute(query, args) 
File "/home/elie/.django-projects/showpill/local/lib/python2.7/site-packages/MySQLdb/cursors.py" in execute 
    174.    self.errorhandler(self, exc, value) 
File "/home/elie/.django-projects/showpill/local/lib/python2.7/site-packages/MySQLdb/connections.py" in defaulterrorhandler 
    36.  raise errorclass, errorvalue 

Exception Type: DatabaseError at /accounts/signup/ 
Exception Value: (1146, "Table 'demo_project.userena_userenasignup' doesn't exist") 

第二編輯

這是syncdb

Syncing... 
Creating tables ... 
Installing custom SQL ... 
Installing indexes ... 
No fixtures found. 

Synced: 
> django.contrib.auth 
> django.contrib.contenttypes 
> django.contrib.sessions 
> django.contrib.sites 
> django.contrib.messages 
> django.contrib.admin 
> south 
> demo_project.profiles 

Not synced (use migrations): 
- easy_thumbnails 
- guardian 
- userena 
- userena.contrib.umessages 
(use ./manage.py migrate to migrate these) 

輸出這是./manage.py migrate

Running migrations for easy_thumbnails: 
- Nothing to migrate. 
- Loading initial data for easy_thumbnails. 
No fixtures found. 
Running migrations for guardian: 
- Nothing to migrate. 
- Loading initial data for guardian. 
No fixtures found. 
Running migrations for userena: 
- Nothing to migrate. 
- Loading initial data for userena. 
No fixtures found. 
Running migrations for umessages: 
- Nothing to migrate. 
- Loading initial data for umessages. 
No fixtures found. 

輸出請注意,eventhough我看到錯誤,用戶名和電子郵件被保存在數據庫中。

如果我登錄,它說:your account has been disabled

,如果我嘗試重置密碼,它說

That e-mail address doesn't have an associated user account. Are you sure you've registered?

+0

@Mat對不起,先生,你是對的,我只是認爲這個錯誤很大,所以我儘量保持儘可能短的問題,但你是對的,我會從現在開始做 – user 2012-03-06 10:54:18

回答

3

我認爲你需要刪除你的數據庫。然後在新鮮的數據庫上再次執行manage.py syncdbmanage.py migrate。當你運行manage.py migrate它不應該給你你發佈的輸出。您的輸出不會更改或創建任何表格,這可能是問題。也許你需要的表格尚未創建。

  1. This is what the output should look like after a manage.py syncdb.
  2. This is what the output should look like after a manage.py migrate.

你應該有21個表格用於提供userena的demo_project。


對於一般幫助的步驟來獲得這個項目的工作應該是。

  1. 創建虛擬環境,並pip install django-userena
  2. 拉出附帶userena
  3. 激活virtualenv中,cd到項目目錄的demo_project,做你的manage.py syncdbmanage.py migrate
  4. 運行該項目

我已經完成了這個,現在可以確認t如果完成這些步驟,則demo_project將起作用。

*請記住,如果您在/accounts/signup/頁面上註冊用戶。該用戶默認情況下將無法登錄/admin/。除非您在管理員中給他一個配置文件,否則您的超級用戶將無法訪問/accounts/(profile)/下的個人資料。

+0

所以看到[this](http://pastebin.com/KjJBgrb9)錯誤是正常的? – user 2012-03-09 00:46:33

+0

不,這不正常。你應該沒有任何錯誤。什麼時候發生錯誤?當您嘗試註冊新用戶時會發生嗎? – darren 2012-03-09 08:09:43

+0

是的,在註冊之後,'syncdb'和'migrate'的輸出就像你描述的那樣是可執行的 – user 2012-03-09 10:20:31

5

你需要運行執行syncdb:manage.py syncdb

你已經計算出你還需要使用各種南方的命令。

現在有兩個問題出現:你是否仍然在跑南(我假設你是)後出現這些錯誤;其次,錯誤消息(Exception Value: (1146, "Table 'demo_project.userena_userenasignup' doesn't exist"))中指定的表是否確實存在?檢查數據庫以確定表是否存在,如果存在,是否存在於正確的數據庫中。

+0

請閱讀我的編輯坐在 – user 2012-03-07 09:26:03

+0

@user:當你運行syncdb時你沒有得到那個錯誤。 – Marcin 2012-03-07 12:18:19

+0

我得到了第一個錯誤,因爲我沒有運行syncdb,但運行syncdb後出現第二個錯誤 – user 2012-03-07 18:31:19