开发者

Django, create_user giving error, manually creating user gives different error

开发者 https://www.devze.com 2022-12-16 02:00 出处:网络
Working with Django 1.1 on Python 2.6.4, trying to execute the following: user = User.objects.create_user(username, email, password)

Working with Django 1.1 on Python 2.6.4, trying to execute the following:

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

The three values are from form.cleaned_data, and have already been validated. i get this error:

'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'

So then i tried to create a user manually using this:

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

and i get this error:

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

Anyone else gotten these errors and know what i am doing wrong?


Seems like email_address is not really a string ('dict' object has no attribute 'strip'), can you dump for us the values of username, email and password?

0

精彩评论

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