got unicode instance instead set_password with django

172 views
Skip to first unread message

cyp

unread,
Dec 15, 2011, 12:10:03 PM12/15/11
to couchdbkit
Hello,

I recently discovered the backend couchdbkit. I start with Python and
CouchDB, but I can say it's a magic tool for me. Really a nice job.

I'm stuck when creating a password when a user registers.
For that I use django_couchdb_utils

In the shell, it's great here easily ;)

>>> u = User(username='cypress6', email='c...@magik-cypress.fr', password='coucou')
>>> u.set_password('coucou')
>>> u.save()
{'username': u'cyp', 'doc_type': 'User', 'first_name': None,
'last_name': None, 'is_active': True, 'is_superuser': False,
'is_staff': False, 'last_login': None, 'password': u'sha1$a301f
$94e6c6c9cf8fcd598e021cb1c4ab31c7d8954aac', 'email':
u'c...@myname.org', 'date_joined': '2011-12-15T16:46:29Z'}
>>> u.check_password('bad')
False
>>> u.check_password('coucou')
True

But when I use it in one of my views with Django. Django returns me an
error that I do not understand.

from django_couchdb_utils.auth.models import User

entry_type = User
password = entry_type.set_password(form.cleaned_data['password'])
if password:
entry.append(password)

Django Version: 1.2.5
Exception Type: TypeError
Exception Value:
unbound method set_password() must be called with User instance as
first argument (got unicode instance instead)

What a problem with unicode ?

Regards,

cyp

Reply all
Reply to author
Forward
0 new messages