2010-01-06 38 views
0

上的Python 2.6.4使用Django 1.1工作,試圖執行以下操作:Django的,create_user給錯誤,手動創建用戶提供了不同的錯誤

user = User.objects.create_user(username, email, password) 

的三個值是從form.cleaned_data,並且已經已經過驗證。我得到這個錯誤:

'dict' object has no attribute 'strip' 
Traceback: 
File "/usr/lib/pymodules/python2.6/django/core/handlers/base.py" in get_response 
    92.     response = callback(request, *callback_args, **callback_kwargs) 
File "/home/jason/bandistry/../bandistry/musician/views.py" in signup 
    140.    user = User.objects.create_user(username, email_address, password) 
File "/usr/lib/pymodules/python2.6/django/contrib/auth/models.py" in create_user 
    100.   user = self.model(None, username, '', '', email.strip().lower(), 'placeholder', False, True, False, now, now) 

Exception Type: AttributeError at /musician/signup 
Exception Value: 'dict' object has no attribute 'strip' 

於是我試圖創建一個用戶手動使用此:

user = User(username=username, email=email_address) 
user.set_password(password) 
user.is_active = True 
user.save() 

和我得到這個錯誤:

Traceback: 
File "/usr/lib/pymodules/python2.6/django/core/handlers/base.py" in get_response 
    92.     response = callback(request, *callback_args, **callback_kwargs) 
File "/home/jason/bandistry/../bandistry/musician/views.py" in signup 
    144.    user.save() 
File "/usr/lib/pymodules/python2.6/django/db/models/base.py" in save 
    410.   self.save_base(force_insert=force_insert, force_update=force_update) 
File "/usr/lib/pymodules/python2.6/django/db/models/base.py" in save_base 
    495.      result = manager._insert(values, return_id=update_pk) 
File "/usr/lib/pymodules/python2.6/django/db/models/manager.py" in _insert 
    177.   return insert_query(self.model, values, **kwargs) 
File "/usr/lib/pymodules/python2.6/django/db/models/query.py" in insert_query 
    1087.  return query.execute_sql(return_id) 
File "/usr/lib/pymodules/python2.6/django/db/models/sql/subqueries.py" in execute_sql 
    320.   cursor = super(InsertQuery, self).execute_sql(None) 
File "/usr/lib/pymodules/python2.6/django/db/models/sql/query.py" in execute_sql 
    2369.   cursor.execute(sql, params) 
File "/usr/lib/pymodules/python2.6/django/db/backends/util.py" in execute 
    19.    return self.cursor.execute(sql, params) 
File "/usr/lib/pymodules/python2.6/django/db/backends/mysql/base.py" in execute 
    84.    return self.cursor.execute(query, args) 
File "/usr/lib/pymodules/python2.6/MySQLdb/cursors.py" in execute 
    151.    query = query % db.literal(args) 
File "/usr/lib/pymodules/python2.6/MySQLdb/connections.py" in literal 
    247.   return self.escape(o, self.encoders) 
File "/usr/lib/pymodules/python2.6/MySQLdb/connections.py" in unicode_literal 
    185.     return db.literal(u.encode(unicode_literal.charset)) 
File "/usr/lib/pymodules/python2.6/MySQLdb/connections.py" in literal 
    247.   return self.escape(o, self.encoders) 

Exception Type: RuntimeError at /musician/signup 
Exception Value: maximum recursion depth exceeded 

任何人都得到了這些錯誤,並知道我做錯了什麼?

回答

2

似乎email_address實際上不是一個字符串('dict'對象沒有屬性'strip'),你可以爲我們輸入用戶名,電子郵件和密碼的值嗎?

+0

我想通了。我有一個clean_email_address驗證函數,它返回完整的deleted_data字典而不僅僅是電子郵件地址。 – 2010-01-06 13:51:31