Skip to content

Instantly share code, notes, and snippets.

@shrey27tri01
Last active January 8, 2021 02:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shrey27tri01/05fae99c0778f517d27f2cf18c12c2b3 to your computer and use it in GitHub Desktop.
Save shrey27tri01/05fae99c0778f517d27f2cf18c12c2b3 to your computer and use it in GitHub Desktop.
Traceback when logging in on localhost on TWLight
Environment:
Request Method: GET
Request URL: http://localhost/oauth/callback/?oauth_verifier=8d09dc0ad5baf43c9cad879ec2d91ae0&oauth_token=4604d6bb5de922be7e14927c7f8b98b7
Django Version: 3.0.11
Python Version: 3.8.2
Installed Applications:
['annoying',
'crispy_forms',
'reversion',
'dal',
'dal_select2',
'django_comments',
'django_cron',
'django_filters',
'modeltranslation',
'taggit',
'request',
'django_countries',
'rest_framework',
'rest_framework.authtoken',
'django.contrib.admin',
'django.contrib.admindocs',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'whitenoise.runserver_nostatic',
'django.contrib.staticfiles',
'django.contrib.sites',
'TWLight.i18n',
'TWLight.users',
'TWLight.resources',
'TWLight.applications',
'TWLight.emails',
'TWLight.graphs',
'TWLight.comments',
'TWLight.api',
'TWLight.ezproxy',
'djmail',
'django_nose']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
'whitenoise.middleware.WhiteNoiseMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.admindocs.middleware.XViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'request.middleware.RequestMiddleware']
Traceback (most recent call last):
File "/app/TWLight/users/oauth.py", line 163, in _get_and_update_user_from_identity
editor.update_from_wikipedia(
File "/app/TWLight/users/models.py", line 663, in update_from_wikipedia
self.update_bundle_authorization()
File "/app/TWLight/users/models.py", line 546, in update_bundle_authorization
twl_team = User.objects.get(username="TWL Team")
File "/venv/lib/python3.8/site-packages/django/db/models/manager.py", line 82, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/venv/lib/python3.8/site-packages/django/db/models/query.py", line 415, in get
raise self.model.DoesNotExist(
During handling of the above exception (User matching query does not exist.), another exception occurred:
File "/venv/lib/python3.8/site-packages/django/db/backends/utils.py", line 86, in _execute
return self.cursor.execute(sql, params)
File "/venv/lib/python3.8/site-packages/django/db/backends/mysql/base.py", line 74, in execute
return self.cursor.execute(query, args)
File "/venv/lib/python3.8/site-packages/MySQLdb/cursors.py", line 206, in execute
res = self._query(query)
File "/venv/lib/python3.8/site-packages/MySQLdb/cursors.py", line 319, in _query
db.query(q)
File "/venv/lib/python3.8/site-packages/MySQLdb/connections.py", line 259, in query
_mysql.connection.query(self, query)
The above exception ((1062, "Duplicate entry '64010842' for key 'username'")) was the direct cause of the following exception:
File "/venv/lib/python3.8/site-packages/django/core/handlers/exception.py", line 34, in inner
response = get_response(request)
File "/venv/lib/python3.8/site-packages/django/core/handlers/base.py", line 115, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/venv/lib/python3.8/site-packages/django/core/handlers/base.py", line 113, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/venv/lib/python3.8/site-packages/django/views/generic/base.py", line 71, in view
return self.dispatch(request, *args, **kwargs)
File "/venv/lib/python3.8/site-packages/django/views/generic/base.py", line 97, in dispatch
return handler(request, *args, **kwargs)
File "/app/TWLight/users/oauth.py", line 428, in get
user = authenticate(
File "/venv/lib/python3.8/site-packages/django/contrib/auth/__init__.py", line 72, in authenticate
user = backend.authenticate(request, **credentials)
File "/app/TWLight/users/oauth.py", line 225, in authenticate
user, created = self._get_and_update_user_from_identity(identity)
File "/app/TWLight/users/oauth.py", line 182, in _get_and_update_user_from_identity
user, editor = self._create_user_and_editor(identity)
File "/app/TWLight/users/oauth.py", line 134, in _create_user_and_editor
user = self._create_user(identity)
File "/app/TWLight/users/oauth.py", line 115, in _create_user
user = User.objects.create_user(username=username, email=email)
File "/venv/lib/python3.8/site-packages/django/contrib/auth/models.py", line 147, in create_user
return self._create_user(username, email, password, **extra_fields)
File "/venv/lib/python3.8/site-packages/django/contrib/auth/models.py", line 141, in _create_user
user.save(using=self._db)
File "/venv/lib/python3.8/site-packages/django/contrib/auth/base_user.py", line 66, in save
super().save(*args, **kwargs)
File "/venv/lib/python3.8/site-packages/django/db/models/base.py", line 748, in save
self.save_base(using=using, force_insert=force_insert,
File "/venv/lib/python3.8/site-packages/django/db/models/base.py", line 785, in save_base
updated = self._save_table(
File "/venv/lib/python3.8/site-packages/django/db/models/base.py", line 890, in _save_table
results = self._do_insert(cls._base_manager, using, fields, returning_fields, raw)
File "/venv/lib/python3.8/site-packages/django/db/models/base.py", line 927, in _do_insert
return manager._insert(
File "/venv/lib/python3.8/site-packages/django/db/models/manager.py", line 82, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/venv/lib/python3.8/site-packages/django/db/models/query.py", line 1204, in _insert
return query.get_compiler(using=using).execute_sql(returning_fields)
File "/venv/lib/python3.8/site-packages/django/db/models/sql/compiler.py", line 1394, in execute_sql
cursor.execute(sql, params)
File "/venv/lib/python3.8/site-packages/django/db/backends/utils.py", line 100, in execute
return super().execute(sql, params)
File "/venv/lib/python3.8/site-packages/django/db/backends/utils.py", line 68, in execute
return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
File "/venv/lib/python3.8/site-packages/django/db/backends/utils.py", line 77, in _execute_with_wrappers
return executor(sql, params, many, context)
File "/venv/lib/python3.8/site-packages/django/db/backends/utils.py", line 86, in _execute
return self.cursor.execute(sql, params)
File "/venv/lib/python3.8/site-packages/django/db/utils.py", line 90, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/venv/lib/python3.8/site-packages/django/db/backends/utils.py", line 86, in _execute
return self.cursor.execute(sql, params)
File "/venv/lib/python3.8/site-packages/django/db/backends/mysql/base.py", line 74, in execute
return self.cursor.execute(query, args)
File "/venv/lib/python3.8/site-packages/MySQLdb/cursors.py", line 206, in execute
res = self._query(query)
File "/venv/lib/python3.8/site-packages/MySQLdb/cursors.py", line 319, in _query
db.query(q)
File "/venv/lib/python3.8/site-packages/MySQLdb/connections.py", line 259, in query
_mysql.connection.query(self, query)
Exception Type: IntegrityError at /oauth/callback/
Exception Value: (1062, "Duplicate entry '64010842' for key 'username'")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment