Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate entry 'ErwinFeser' for key 'username' #12

Closed
erwinfeser opened this issue Jan 16, 2011 · 1 comment
Closed

Duplicate entry 'ErwinFeser' for key 'username' #12

erwinfeser opened this issue Jan 16, 2011 · 1 comment
Labels

Comments

@erwinfeser
Copy link

If an user login using different services (Google, Twitter, etc) and the user has the same username for at least two, Django raises an IntegrityError exception because it try to create more than one django account with the same username.

I pasted a debug page example below:

Environment:

Request Method: GET
Request URL: http://www.erwinfeser.com.ar/...
Django Version: 1.2.3
Python Version: 2.6.5
Installed Applications:
['tinymce',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.admin',
'feserwin.erwinsite',
'feserwin.teg7',
'social_auth']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.middleware.csrf.CsrfResponseMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware')

Traceback:
File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/base.py" in get_response

  1.                 response = callback(request, _callback_args, *_callback_kwargs)
    
    File "/usr/local/lib/python2.6/dist-packages/social_auth/views.py" in complete
  2. user = backend.auth_complete()
    
    File "/usr/local/lib/python2.6/dist-packages/social_auth/auth.py" in auth_complete
  3.         return authenticate(_args, *_kwargs)
    
    File "/usr/local/lib/python2.6/dist-packages/django/contrib/auth/init.py" in authenticate
  4.         user = backend.authenticate(**credentials)
    
    File "/usr/local/lib/python2.6/dist-packages/social_auth/backends.py" in authenticate
  5.     self.update_user_details(user, response, details, new_user=new_user)
    
    File "/usr/local/lib/python2.6/dist-packages/social_auth/backends.py" in update_user_details
  6.         user.save()
    
    File "/usr/local/lib/python2.6/dist-packages/django/db/models/base.py" in save
  7.     self.save_base(using=using, force_insert=force_insert, force_update=force_update)
    
    File "/usr/local/lib/python2.6/dist-packages/django/db/models/base.py" in save_base
  8.                     rows = manager.using(using).filter(pk=pk_val)._update(values)
    
    File "/usr/local/lib/python2.6/dist-packages/django/db/models/query.py" in _update
  9.     return query.get_compiler(self.db).execute_sql(None)
    
    File "/usr/local/lib/python2.6/dist-packages/django/db/models/sql/compiler.py" in execute_sql
  10.     cursor = super(SQLUpdateCompiler, self).execute_sql(result_type)
    
    File "/usr/local/lib/python2.6/dist-packages/django/db/models/sql/compiler.py" in execute_sql
  11.     cursor.execute(sql, params)
    
    File "/usr/local/lib/python2.6/dist-packages/django/db/backends/util.py" in execute
  12.         return self.cursor.execute(sql, params)
    
    File "/usr/local/lib/python2.6/dist-packages/django/db/backends/mysql/base.py" in execute
  13.         return self.cursor.execute(query, args)
    
    File "/usr/lib/pymodules/python2.6/MySQLdb/cursors.py" in execute
  14.         self.errorhandler(self, exc, value)
    
    File "/usr/lib/pymodules/python2.6/MySQLdb/connections.py" in defaulterrorhandler
  15. raise errorclass, errorvalue
    

Exception Type: IntegrityError at /site/social-auth/complete/google/
Exception Value: (1062, "Duplicate entry 'ErwinFeser' for key 'username'")

@omab
Copy link
Owner

omab commented Jan 17, 2011

Remove username update, username is already generated and loaded in user instance. Closed by f42fc57

caioariede pushed a commit to caioariede/django-social-auth that referenced this issue May 23, 2013
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants