danfairs/django-lazysignup — Issue #15: IntegrityError when trying to access allow_lazy_user protected view
Author: rockyburt
Created: 2012-01-31 21:20:18+00:00
State: open

I was setting up django-lazysignup 0.7.0 for the first time against a SQLite3 db. I'm running Django 1.3. I get an error when I access a view protected by allow_lazy_user. The code that hooks up allow_lazy_user is:

urlpatterns = patterns('',
url(r'^app/(?P.*)/deploy$',
allow_lazy_user(views.DeployView.as_view()),
name='app_project_deploy'),
)

The error I get indicates a name collision which is practically impossible since the only user in the db is the admin user.

Traceback (most recent call last):
File "/home/rocky/dev/envs/jazkarta/appsembler/env-appsembler/lib/python2.7/site-packages/django/contrib/staticfiles/handlers.py", line 68, in __call__
return self.application(environ, start_response)
File "/home/rocky/dev/envs/jazkarta/appsembler/env-appsembler/lib/python2.7/site-packages/django/contrib/staticfiles/handlers.py", line 68, in __call__
return self.application(environ, start_response)
File "/home/rocky/dev/envs/jazkarta/appsembler/env-appsembler/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 272, in __call__
response = self.get_response(request)
File "/home/rocky/dev/envs/jazkarta/appsembler/env-appsembler/lib/python2.7/site-packages/django/core/handlers/base.py", line 169, in get_response
response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
File "/home/rocky/dev/envs/jazkarta/appsembler/env-appsembler/lib/python2.7/site-packages/django/core/handlers/base.py", line 203, in handle_uncaught_exception
return debug.technical_500_response(request, *exc_info)
File "/home/rocky/dev/envs/jazkarta/appsembler/env-appsembler/lib/python2.7/site-packages/django/core/handlers/base.py", line 111, in get_response
response = callback(request, *callback_args, **callback_kwargs)
File "/home/rocky/dev/envs/jazkarta/appsembler/env-appsembler/lib/python2.7/site-packages/lazysignup/decorators.py", line 33, in wrapped
user = LazyUser.objects.create_lazy_user(username)
File "/home/rocky/dev/envs/jazkarta/appsembler/env-appsembler/lib/python2.7/site-packages/lazysignup/models.py", line 29, in create_lazy_user
user = user_class.objects.create_user(username, '')
File "/home/rocky/dev/envs/jazkarta/appsembler/env-appsembler/lib/python2.7/site-packages/django/contrib/auth/models.py", line 136, in create_user
user.save(using=self._db)
File "/home/rocky/dev/envs/jazkarta/appsembler/env-appsembler/lib/python2.7/site-packages/django/db/models/base.py", line 460, in save
self.save_base(using=using, force_insert=force_insert, force_update=force_update)
File "/home/rocky/dev/envs/jazkarta/appsembler/env-appsembler/lib/python2.7/site-packages/django/db/models/base.py", line 553, in save_base
result = manager._insert(values, return_id=update_pk, using=using)
File "/home/rocky/dev/envs/jazkarta/appsembler/env-appsembler/lib/python2.7/site-packages/django/db/models/manager.py", line 195, in _insert
return insert_query(self.model, values, **kwargs)
File "/home/rocky/dev/envs/jazkarta/appsembler/env-appsembler/lib/python2.7/site-packages/django/db/models/query.py", line 1436, in insert_query
return query.get_compiler(using=using).execute_sql(return_id)
File "/home/rocky/dev/envs/jazkarta/appsembler/env-appsembler/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 791, in execute_sql
cursor = super(SQLInsertCompiler, self).execute_sql(None)
File "/home/rocky/dev/envs/jazkarta/appsembler/env-appsembler/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 735, in execute_sql
cursor.execute(sql, params)
File "/home/rocky/dev/envs/jazkarta/appsembler/env-appsembler/lib/python2.7/site-packages/django/db/backends/util.py", line 34, in execute
return self.cursor.execute(sql, params)
File "/home/rocky/dev/envs/jazkarta/appsembler/env-appsembler/lib/python2.7/site-packages/django/db/backends/sqlite3/base.py", line 234, in execute
return Database.Cursor.execute(self, query, params)
IntegrityError: column username is not unique