Having a nullable OneToOneField and trying to persist two different objects with that field = null causes E11000 duplicate key error
Python script
I found that error when trying to implement django-rest-framework-social-oauth2 with a Djongo database backend. The following is the model that's throwing the error:
source_refresh_token = models.OneToOneField(
# unique=True implied by the OneToOneField
oauth2_settings.REFRESH_TOKEN_MODEL, on_delete=models.SET_NULL, blank=True, null=True,
related_name="refreshed_access_token"
)
When I'm signing in with the first user, it creates the register in the collection with source_refresh_token = null:
This is a SQL Server bug. The code is correctly using OneToOneField.
SQL Server does not properly implement the UNIQUE NULL constraint in which no two NULLs are equal.
There is a workaround that involves changing the CREATE UNIQUE INDEX to have WHERE _field_ is NOT NULL.
But I can't quite implement that workaround since I'm not using SQL Server but rather Djongo, which seems to be the source of the problem.
File "/home/gabo/miniconda2/envs/jager_server/lib/python3.7/site-packages/rest_framework/views.py" in dispatch
response = self.handle_exception(exc)
File "/home/gabo/miniconda2/envs/jager_server/lib/python3.7/site-packages/rest_framework/views.py" in handle_exception
self.raise_uncaught_exception(exc)
File "/home/gabo/miniconda2/envs/jager_server/lib/python3.7/site-packages/rest_framework/views.py" in raise_uncaught_exception
raise exc
File "/home/gabo/miniconda2/envs/jager_server/lib/python3.7/site-packages/rest_framework/views.py" in dispatch
response = handler(request, *args, **kwargs)
File "/home/gabo/miniconda2/envs/jager_server/lib/python3.7/site-packages/rest_framework_social_oauth2/views.py" in post
url, headers, body, status = self.create_token_response(request._request)
File "/home/gabo/miniconda2/envs/jager_server/lib/python3.7/site-packages/oauth2_provider/views/mixins.py" in create_token_response
return core.create_token_response(request)
File "/home/gabo/miniconda2/envs/jager_server/lib/python3.7/site-packages/oauth2_provider/oauth2_backends.py" in create_token_response
headers, extra_credentials)
File "/home/gabo/miniconda2/envs/jager_server/lib/python3.7/site-packages/oauthlib/oauth2/rfc6749/endpoints/base.py" in wrapper
return f(endpoint, uri, *args, **kwargs)
File "/home/gabo/miniconda2/envs/jager_server/lib/python3.7/site-packages/rest_framework_social_oauth2/oauth2_endpoints.py" in create_token_response
request, self.default_token_type)
File "/home/gabo/miniconda2/envs/jager_server/lib/python3.7/site-packages/oauthlib/oauth2/rfc6749/grant_types/refresh_token.py" in create_token_response
self.request_validator.save_token(token, request)
File "/home/gabo/miniconda2/envs/jager_server/lib/python3.7/site-packages/oauthlib/oauth2/rfc6749/request_validator.py" in save_token
You're seeing this error because you have DEBUG = True in your
Django settings file. Change that to False, and Django will
display a standard page generated by the handler for this status code.
One line description of the issue
Having a nullable OneToOneField and trying to persist two different objects with that field = null causes E11000 duplicate key error
Python script
I found that error when trying to implement django-rest-framework-social-oauth2 with a Djongo database backend. The following is the model that's throwing the error:
When I'm signing in with the first user, it creates the register in the collection with source_refresh_token = null:
Trying to sign in a new user, which'll create a new instance of the access_token, throws the error:
E11000 duplicate key error collection: jager_database.oauth2_provider_accesstoken index: source_refresh_token_id dup key: { source_refresh_token_id: null }
This issue is referenced on the django-oauth-toolkit repository https://github.com/jazzband/django-oauth-toolkit/issues/663, where the answer was that the problem lied in the SQL parser:
https://github.com/jazzband/django-oauth-toolkit/issues/663#issuecomment-439638610
But I can't quite implement that workaround since I'm not using SQL Server but rather Djongo, which seems to be the source of the problem.
Traceback
SQLDecodeError at /api/auth/oauth/convert-token/ FAILED SQL: INSERT INTO "oauth2_provider_accesstoken" ("user_id", "source_refresh_token_id", "token", "application_id", "expires", "scope", "created", "updated") VALUES (%(0)s, %(1)s, %(2)s, %(3)s, %(4)s, %(5)s, %(6)s, %(7)s) Params: [23, None, 'Q857RCjJhDtlJrLv78eeumcQKx4W8r', 1, datetime.datetime(2021, 7, 14, 17, 2, 32, 457244), 'read write', datetime.datetime(2020, 7, 14, 17, 2, 32, 457913), datetime.datetime(2020, 7, 14, 17, 2, 32, 457937)] Pymongo error: {'writeErrors': [{'index': 0, 'code': 11000, 'keyPattern': {'source_refresh_token_id': 1}, 'keyValue': {'source_refresh_token_id': None}, 'errmsg': 'E11000 duplicate key error collection: jager_database.oauth2_provider_accesstoken index: source_refresh_token_id dup key: { source_refresh_token_id: null }', 'op': {'id': 31, 'user_id': 23, 'source_refresh_token_id': None, 'token': 'Q857RCjJhDtlJrLv78eeumcQKx4W8r', 'application_id': 1, 'expires': datetime.datetime(2021, 7, 14, 17, 2, 32, 457244), 'scope': 'read write', 'created': datetime.datetime(2020, 7, 14, 17, 2, 32, 457913), 'updated': datetime.datetime(2020, 7, 14, 17, 2, 32, 457937), '_id': ObjectId('5f0de52818aef6b4d9c87cbe')}}], 'writeConcernErrors': [], 'nInserted': 0, 'nUpserted': 0, 'nMatched': 0, 'nModified': 0, 'nRemoved': 0, 'upserted': []} Version: 1.3.1
Request Method: POST Request URL: http://localhost:8000/api/auth/oauth/convert-token/ Django Version: 2.2.13 Python Executable: /home/gabo/miniconda2/envs/jager_server/bin/python Python Version: 3.7.7 Python Path: ['/home/gabo/Laboratorio 3/jager_server', '/home/gabo/miniconda2/envs/jager_server/lib/python37.zip', '/home/gabo/miniconda2/envs/jager_server/lib/python3.7', '/home/gabo/miniconda2/envs/jager_server/lib/python3.7/lib-dynload', '/home/gabo/miniconda2/envs/jager_server/lib/python3.7/site-packages'] Server time: Mar, 14 Jul 2020 17:02:32 +0000 Installed Applications: ['admin_interface', 'colorfield', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'rest_framework', 'django_better_admin_arrayfield', 'core', 'rest', 'oauth2_provider', 'social_django', 'rest_framework_social_oauth2', 'rest_framework.authtoken'] Installed Middleware: ['django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware']
Traceback:
File "/home/gabo/miniconda2/envs/jager_server/lib/python3.7/site-packages/djongo/sql2mongo/query.py" in parse
File "/home/gabo/miniconda2/envs/jager_server/lib/python3.7/site-packages/djongo/sql2mongo/query.py" in _insert
File "/home/gabo/miniconda2/envs/jager_server/lib/python3.7/site-packages/djongo/sql2mongo/query.py" in execute
File "/home/gabo/miniconda2/envs/jager_server/lib/python3.7/site-packages/pymongo/collection.py" in insert_many
File "/home/gabo/miniconda2/envs/jager_server/lib/python3.7/site-packages/pymongo/bulk.py" in execute
File "/home/gabo/miniconda2/envs/jager_server/lib/python3.7/site-packages/pymongo/bulk.py" in execute_command
File "/home/gabo/miniconda2/envs/jager_server/lib/python3.7/site-packages/pymongo/bulk.py" in _raise_bulk_write_error
The above exception (batch op errors occurred) was the direct cause of the following exception:
File "/home/gabo/miniconda2/envs/jager_server/lib/python3.7/site-packages/django/core/handlers/exception.py" in inner
File "/home/gabo/miniconda2/envs/jager_server/lib/python3.7/site-packages/django/core/handlers/base.py" in _get_response
File "/home/gabo/miniconda2/envs/jager_server/lib/python3.7/site-packages/django/core/handlers/base.py" in _get_response
File "/home/gabo/miniconda2/envs/jager_server/lib/python3.7/site-packages/django/views/decorators/csrf.py" in wrapped_view
File "/home/gabo/miniconda2/envs/jager_server/lib/python3.7/site-packages/django/views/generic/base.py" in view
File "/home/gabo/miniconda2/envs/jager_server/lib/python3.7/site-packages/django/utils/decorators.py" in _wrapper
File "/home/gabo/miniconda2/envs/jager_server/lib/python3.7/site-packages/django/views/decorators/csrf.py" in wrapped_view
File "/home/gabo/miniconda2/envs/jager_server/lib/python3.7/site-packages/braces/views/_forms.py" in dispatch
File "/home/gabo/miniconda2/envs/jager_server/lib/python3.7/site-packages/rest_framework/views.py" in dispatch
File "/home/gabo/miniconda2/envs/jager_server/lib/python3.7/site-packages/rest_framework/views.py" in handle_exception
File "/home/gabo/miniconda2/envs/jager_server/lib/python3.7/site-packages/rest_framework/views.py" in raise_uncaught_exception
File "/home/gabo/miniconda2/envs/jager_server/lib/python3.7/site-packages/rest_framework/views.py" in dispatch
File "/home/gabo/miniconda2/envs/jager_server/lib/python3.7/site-packages/rest_framework_social_oauth2/views.py" in post
File "/home/gabo/miniconda2/envs/jager_server/lib/python3.7/site-packages/oauth2_provider/views/mixins.py" in create_token_response
File "/home/gabo/miniconda2/envs/jager_server/lib/python3.7/site-packages/oauth2_provider/oauth2_backends.py" in create_token_response
File "/home/gabo/miniconda2/envs/jager_server/lib/python3.7/site-packages/oauthlib/oauth2/rfc6749/endpoints/base.py" in wrapper
File "/home/gabo/miniconda2/envs/jager_server/lib/python3.7/site-packages/rest_framework_social_oauth2/oauth2_endpoints.py" in create_token_response
File "/home/gabo/miniconda2/envs/jager_server/lib/python3.7/site-packages/oauthlib/oauth2/rfc6749/grant_types/refresh_token.py" in create_token_response
File "/home/gabo/miniconda2/envs/jager_server/lib/python3.7/site-packages/oauthlib/oauth2/rfc6749/request_validator.py" in save_token
File "/home/gabo/miniconda2/envs/jager_server/lib/python3.7/contextlib.py" in inner
File "/home/gabo/miniconda2/envs/jager_server/lib/python3.7/site-packages/oauth2_provider/oauth2_validators.py" in save_bearer_token
File "/home/gabo/miniconda2/envs/jager_server/lib/python3.7/site-packages/oauth2_provider/oauth2_validators.py" in _create_access_token
File "/home/gabo/miniconda2/envs/jager_server/lib/python3.7/site-packages/django/db/models/manager.py" in manager_method
File "/home/gabo/miniconda2/envs/jager_server/lib/python3.7/site-packages/django/db/models/query.py" in create
File "/home/gabo/miniconda2/envs/jager_server/lib/python3.7/site-packages/django/db/models/base.py" in save
File "/home/gabo/miniconda2/envs/jager_server/lib/python3.7/site-packages/django/db/models/base.py" in save_base
File "/home/gabo/miniconda2/envs/jager_server/lib/python3.7/site-packages/django/db/models/base.py" in _save_table
File "/home/gabo/miniconda2/envs/jager_server/lib/python3.7/site-packages/django/db/models/base.py" in _do_insert
File "/home/gabo/miniconda2/envs/jager_server/lib/python3.7/site-packages/django/db/models/manager.py" in manager_method
File "/home/gabo/miniconda2/envs/jager_server/lib/python3.7/site-packages/django/db/models/query.py" in _insert
File "/home/gabo/miniconda2/envs/jager_server/lib/python3.7/site-packages/django/db/models/sql/compiler.py" in execute_sql
File "/home/gabo/miniconda2/envs/jager_server/lib/python3.7/site-packages/django/db/backends/utils.py" in execute
File "/home/gabo/miniconda2/envs/jager_server/lib/python3.7/site-packages/django/db/backends/utils.py" in execute
File "/home/gabo/miniconda2/envs/jager_server/lib/python3.7/site-packages/django/db/backends/utils.py" in _execute_with_wrappers
File "/home/gabo/miniconda2/envs/jager_server/lib/python3.7/site-packages/django/db/backends/utils.py" in _execute
File "/home/gabo/miniconda2/envs/jager_server/lib/python3.7/site-packages/djongo/cursor.py" in execute
File "/home/gabo/miniconda2/envs/jager_server/lib/python3.7/site-packages/djongo/sql2mongo/query.py" in init
File "/home/gabo/miniconda2/envs/jager_server/lib/python3.7/site-packages/djongo/sql2mongo/query.py" in parse
Exception Type: SQLDecodeError at /api/auth/oauth/convert-token/ Exception Value: FAILED SQL: INSERT INTO "oauth2_provider_accesstoken" ("user_id", "source_refresh_token_id", "token", "application_id", "expires", "scope", "created", "updated") VALUES (%(0)s, %(1)s, %(2)s, %(3)s, %(4)s, %(5)s, %(6)s, %(7)s) Params: [23, None, 'Q857RCjJhDtlJrLv78eeumcQKx4W8r', 1, datetime.datetime(2021, 7, 14, 17, 2, 32, 457244), 'read write', datetime.datetime(2020, 7, 14, 17, 2, 32, 457913), datetime.datetime(2020, 7, 14, 17, 2, 32, 457937)] Pymongo error: {'writeErrors': [{'index': 0, 'code': 11000, 'keyPattern': {'source_refresh_token_id': 1}, 'keyValue': {'source_refresh_token_id': None}, 'errmsg': 'E11000 duplicate key error collection: jager_database.oauth2_provider_accesstoken index: source_refresh_token_id dup key: { source_refresh_token_id: null }', 'op': {'id': 31, 'user_id': 23, 'source_refresh_token_id': None, 'token': 'Q857RCjJhDtlJrLv78eeumcQKx4W8r', 'application_id': 1, 'expires': datetime.datetime(2021, 7, 14, 17, 2, 32, 457244), 'scope': 'read write', 'created': datetime.datetime(2020, 7, 14, 17, 2, 32, 457913), 'updated': datetime.datetime(2020, 7, 14, 17, 2, 32, 457937), '_id': ObjectId('5f0de52818aef6b4d9c87cbe')}}], 'writeConcernErrors': [], 'nInserted': 0, 'nUpserted': 0, 'nMatched': 0, 'nModified': 0, 'nRemoved': 0, 'upserted': []} Version: 1.3.1 Request information: USER: AnonymousUser
GET: No GET data
POST: grant_type = 'convert_token' client_id = 'LJ6kyCLZwbGg9Cbs82OFNXxqZjbyR3l9VdDQeK1Q' backend = 'google-oauth2' token = ''
FILES: No FILES data
COOKIES: No cookie data
META: COLORTERM = 'truecolor' CONDA_DEFAULT_ENV = 'jager_server' CONDA_EXE = '/home/gabo/miniconda2/bin/conda' CONDA_PREFIX = '/home/gabo/miniconda2/envs/jager_server' CONDA_PREFIX_1 = '/home/gabo/miniconda2' CONDA_PROMPT_MODIFIER = '(jager_server) ' CONDA_PYTHON_EXE = '/home/gabo/miniconda2/bin/python' CONDA_SHLVL = '2' CONTENT_LENGTH = '313' CONTENT_TYPE = 'application/json' DBUS_SESSION_BUS_ADDRESS = 'unix:path=/run/user/1000/bus' DESKTOP_AUTOSTART_ID = '10f9bb7462c218534d159474433061162400000011320000' DESKTOP_SESSION = 'gnome' DJANGO_SETTINGS_MODULE = 'jager_server.settings' GATEWAY_INTERFACE = 'CGI/1.1' GDMSESSION = 'gnome' GDM_LANG = 'es_VE.UTF-8' GIO_LAUNCHED_DESKTOP_FILE = '/usr/share/applications/org.gnome.Shell.desktop' GIO_LAUNCHED_DESKTOP_FILE_PID = '1164' GIT_ASKPASS = '/usr/share/code/resources/app/extensions/git/dist/askpass.sh' GNOME_DESKTOP_SESSION_ID = 'this-is-deprecated' GTK_MODULES = 'gail:atk-bridge' HOME = '/home/gabo' HTTP_ACCEPT = '/' HTTP_ACCEPT_ENCODING = 'gzip, deflate, br' HTTP_CONNECTION = 'keep-alive' HTTP_HOST = 'localhost:8000' HTTP_POSTMAN_TOKEN = '813d97b2-63e6-448e-b6bd-165714ff4558' HTTP_USER_AGENT = 'PostmanRuntime/7.26.1' LANG = 'es_VE.UTF-8' LANGUAGE = 'es_VE:es' LOGNAME = 'gabo' LS_COLORS = 'rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:.tar=01;31:.tgz=01;31:.arc=01;31:.arj=01;31:.taz=01;31:.lha=01;31:.lz4=01;31:.lzh=01;31:.lzma=01;31:.tlz=01;31:.txz=01;31:.tzo=01;31:.t7z=01;31:.zip=01;31:.z=01;31:.dz=01;31:.gz=01;31:.lrz=01;31:.lz=01;31:.lzo=01;31:.xz=01;31:.zst=01;31:.tzst=01;31:.bz2=01;31:.bz=01;31:.tbz=01;31:.tbz2=01;31:.tz=01;31:.deb=01;31:.rpm=01;31:.jar=01;31:.war=01;31:.ear=01;31:.sar=01;31:.rar=01;31:.alz=01;31:.ace=01;31:.zoo=01;31:.cpio=01;31:.7z=01;31:.rz=01;31:.cab=01;31:.wim=01;31:.swm=01;31:.dwm=01;31:.esd=01;31:.jpg=01;35:.jpeg=01;35:.mjpg=01;35:.mjpeg=01;35:.gif=01;35:.bmp=01;35:.pbm=01;35:.pgm=01;35:.ppm=01;35:.tga=01;35:.xbm=01;35:.xpm=01;35:.tif=01;35:.tiff=01;35:.png=01;35:.svg=01;35:.svgz=01;35:.mng=01;35:.pcx=01;35:.mov=01;35:.mpg=01;35:.mpeg=01;35:.m2v=01;35:.mkv=01;35:.webm=01;35:.ogm=01;35:.mp4=01;35:.m4v=01;35:.mp4v=01;35:.vob=01;35:.qt=01;35:.nuv=01;35:.wmv=01;35:.asf=01;35:.rm=01;35:.rmvb=01;35:.flc=01;35:.avi=01;35:.fli=01;35:.flv=01;35:.gl=01;35:.dl=01;35:.xcf=01;35:.xwd=01;35:.yuv=01;35:.cgm=01;35:.emf=01;35:.ogv=01;35:.ogx=01;35:.aac=00;36:.au=00;36:.flac=00;36:.m4a=00;36:.mid=00;36:.midi=00;36:.mka=00;36:.mp3=00;36:.mpc=00;36:.ogg=00;36:.ra=00;36:.wav=00;36:.oga=00;36:.opus=00;36:.spx=00;36:*.xspf=00;36:' PATH = '/home/gabo/miniconda2/envs/jager_server/bin:/home/gabo/miniconda2/condabin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/snap/bin:/home/gabo/.dotnet/tools' PATH_INFO = '/api/auth/oauth/convert-token/' PWD = '/home/gabo/Laboratorio 3/jager_server' QT_ACCESSIBILITY = '1' QUERY_STRING = '' REMOTE_ADDR = '127.0.0.1' REMOTE_HOST = '' REQUEST_METHOD = 'POST' RUN_MAIN = 'true' SCRIPT_NAME = '' SERVER_NAME = 'localhost' SERVER_PORT = '8000' SERVER_PROTOCOL = 'HTTP/1.1' SERVER_SOFTWARE = 'WSGIServer/0.2' SESSION_MANAGER = 'local/localhost:@/tmp/.ICE-unix/1132,unix/localhost:/tmp/.ICE-unix/1132' SHELL = '/bin/bash' SHLVL = '1' SSH_AUTH_SOCK = '/run/user/1000/keyring/ssh' TERM = 'xterm-256color' TERM_PROGRAM = 'vscode' TERM_PROGRAM_VERSION = '1.46.1' TZ = 'UTC' USER = 'gabo' USERNAME = 'gabo' VSCODE_GIT_ASKPASS_MAIN = '/usr/share/code/resources/app/extensions/git/dist/askpass-main.js' VSCODE_GIT_ASKPASS_NODE = '/usr/share/code/code' VSCODE_GIT_IPC_HANDLE = '/run/user/1000/vscode-git-26d0040d41.sock' XDG_CURRENT_DESKTOP = 'GNOME' XDG_DATA_DIRS = '/usr/local/share:/usr/share:/var/lib/snapd/desktop' XDG_MENU_PREFIX = 'gnome-' XDG_RUNTIME_DIR = '/run/user/1000' XDG_SEAT = 'seat0' XDG_SESSION_CLASS = 'user' XDG_SESSION_DESKTOP = 'gnome' XDG_SESSION_ID = '2' XDG_SESSION_TYPE = 'wayland' XDGVTNR = '2' = '/home/gabo/miniconda2/envs/jager_server/bin/python' _CE_CONDA = '' _CE_M = '' wsgi.errors = <_io.TextIOWrapper name='' mode='w' encoding='UTF-8'>
wsgi.file_wrapper = ''
wsgi.input = <django.core.handlers.wsgi.LimitedStream object at 0x7f58ba4361d0>
wsgi.multiprocess = False
wsgi.multithread = True
wsgi.run_once = False
wsgi.url_scheme = 'http'
wsgi.version = '(1, 0)'
Settings: Using settings module jager_server.settings ABSOLUTE_URL_OVERRIDES = {} ADMINS = [] ALLOWED_HOSTS = [] APPEND_SLASH = True AUTHENTICATION_BACKENDS = "('rest_framework_social_oauth2.backends.DjangoOAuth2', 'django.contrib.auth.backends.ModelBackend', 'social_core.backends.google.GoogleOAuth2')" AUTH_PASSWORD_VALIDATORS = '****' AUTH_USER_MODEL = 'auth.User' BASE_DIR = '/home/gabo/Laboratorio 3/jager_server' CACHES = {'default': {'BACKEND': 'django.core.cache.backends.locmem.LocMemCache'}} CACHE_MIDDLEWARE_ALIAS = 'default' CACHE_MIDDLEWARE_KEY_PREFIX = '****' CACHE_MIDDLEWARE_SECONDS = 600 CORS_ALLOW_METHODS = ['DELETE', 'GET', 'OPTIONS', 'PATCH', 'POST', 'PUT'] CSRF_COOKIE_AGE = 31449600 CSRF_COOKIE_DOMAIN = None CSRF_COOKIE_HTTPONLY = False CSRF_COOKIE_NAME = 'csrftoken' CSRF_COOKIE_PATH = '/' CSRF_COOKIE_SAMESITE = 'Lax' CSRF_COOKIE_SECURE = False CSRF_FAILURE_VIEW = 'django.views.csrf.csrf_failure' CSRF_HEADER_NAME = 'HTTP_X_CSRFTOKEN' CSRF_TRUSTED_ORIGINS = [] CSRF_USE_SESSIONS = False DATABASES = {'default': {'ENGINE': 'djongo', 'NAME': 'jager_database', 'ATOMIC_REQUESTS': False, 'AUTOCOMMIT': True, 'CONN_MAX_AGE': 0, 'OPTIONS': {}, 'TIME_ZONE': None, 'USER': '', 'PASSWORD': '****', 'HOST': '', 'PORT': '', 'TEST': {'CHARSET': None, 'COLLATION': None, 'NAME': None, 'MIRROR': None}}} DATABASE_ROUTERS = [] DATA_UPLOAD_MAX_MEMORY_SIZE = 2621440 DATA_UPLOAD_MAX_NUMBER_FIELDS = 1000 DATETIME_FORMAT = 'N j, Y, P' DATETIME_INPUT_FORMATS = ['%Y-%m-%d %H:%M:%S', '%Y-%m-%d %H:%M:%S.%f', '%Y-%m-%d %H:%M', '%Y-%m-%d', '%m/%d/%Y %H:%M:%S', '%m/%d/%Y %H:%M:%S.%f', '%m/%d/%Y %H:%M', '%m/%d/%Y', '%m/%d/%y %H:%M:%S', '%m/%d/%y %H:%M:%S.%f', '%m/%d/%y %H:%M', '%m/%d/%y'] DATE_FORMAT = 'N j, Y' DATE_INPUT_FORMATS = ['%Y-%m-%d', '%m/%d/%Y', '%m/%d/%y', '%b %d %Y', '%b %d, %Y', '%d %b %Y', '%d %b, %Y', '%B %d %Y', '%B %d, %Y', '%d %B %Y', '%d %B, %Y'] DEBUG = True DEBUG_PROPAGATE_EXCEPTIONS = False DECIMAL_SEPARATOR = '.' DEFAULT_CHARSET = 'utf-8' DEFAULT_CONTENT_TYPE = 'text/html' DEFAULT_EXCEPTION_REPORTER_FILTER = 'django.views.debug.SafeExceptionReporterFilter' DEFAULT_FILE_STORAGE = 'django.core.files.storage.FileSystemStorage' DEFAULT_FROM_EMAIL = 'webmaster@localhost' DEFAULT_INDEX_TABLESPACE = '' DEFAULT_TABLESPACE = '' DISALLOWED_USER_AGENTS = [] EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' EMAIL_HOST = 'localhost' EMAIL_HOST_PASSWORD = '****' EMAIL_HOST_USER = '' EMAIL_PORT = 25 EMAIL_SSL_CERTFILE = None EMAIL_SSL_KEYFILE = '****' EMAIL_SUBJECT_PREFIX = '[Django] ' EMAIL_TIMEOUT = None EMAIL_USE_LOCALTIME = False EMAIL_USE_SSL = False EMAIL_USE_TLS = False FILE_CHARSET = 'utf-8' FILE_UPLOAD_DIRECTORY_PERMISSIONS = None FILE_UPLOAD_HANDLERS = ['django.core.files.uploadhandler.MemoryFileUploadHandler', 'django.core.files.uploadhandler.TemporaryFileUploadHandler'] FILE_UPLOAD_MAX_MEMORY_SIZE = 2621440 FILE_UPLOAD_PERMISSIONS = None FILE_UPLOAD_TEMP_DIR = None FIRST_DAY_OF_WEEK = 0 FIXTURE_DIRS = [] FORCE_SCRIPT_NAME = None FORMAT_MODULE_PATH = None FORM_RENDERER = 'django.forms.renderers.DjangoTemplates' IGNORABLE_404_URLS = [] INSTALLED_APPS = ['admin_interface', 'colorfield', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'rest_framework', 'django_better_admin_arrayfield', 'core', 'rest', 'oauth2_provider', 'social_django', 'rest_framework_social_oauth2', 'rest_framework.authtoken'] INTERNAL_IPS = [] LANGUAGES = [('af', 'Afrikaans'), ('ar', 'Arabic'), ('ast', 'Asturian'), ('az', 'Azerbaijani'), ('bg', 'Bulgarian'), ('be', 'Belarusian'), ('bn', 'Bengali'), ('br', 'Breton'), ('bs', 'Bosnian'), ('ca', 'Catalan'), ('cs', 'Czech'), ('cy', 'Welsh'), ('da', 'Danish'), ('de', 'German'), ('dsb', 'Lower Sorbian'), ('el', 'Greek'), ('en', 'English'), ('en-au', 'Australian English'), ('en-gb', 'British English'), ('eo', 'Esperanto'), ('es', 'Spanish'), ('es-ar', 'Argentinian Spanish'), ('es-co', 'Colombian Spanish'), ('es-mx', 'Mexican Spanish'), ('es-ni', 'Nicaraguan Spanish'), ('es-ve', 'Venezuelan Spanish'), ('et', 'Estonian'), ('eu', 'Basque'), ('fa', 'Persian'), ('fi', 'Finnish'), ('fr', 'French'), ('fy', 'Frisian'), ('ga', 'Irish'), ('gd', 'Scottish Gaelic'), ('gl', 'Galician'), ('he', 'Hebrew'), ('hi', 'Hindi'), ('hr', 'Croatian'), ('hsb', 'Upper Sorbian'), ('hu', 'Hungarian'), ('hy', 'Armenian'), ('ia', 'Interlingua'), ('id', 'Indonesian'), ('io', 'Ido'), ('is', 'Icelandic'), ('it', 'Italian'), ('ja', 'Japanese'), ('ka', 'Georgian'), ('kab', 'Kabyle'), ('kk', 'Kazakh'), ('km', 'Khmer'), ('kn', 'Kannada'), ('ko', 'Korean'), ('lb', 'Luxembourgish'), ('lt', 'Lithuanian'), ('lv', 'Latvian'), ('mk', 'Macedonian'), ('ml', 'Malayalam'), ('mn', 'Mongolian'), ('mr', 'Marathi'), ('my', 'Burmese'), ('nb', 'Norwegian Bokmål'), ('ne', 'Nepali'), ('nl', 'Dutch'), ('nn', 'Norwegian Nynorsk'), ('os', 'Ossetic'), ('pa', 'Punjabi'), ('pl', 'Polish'), ('pt', 'Portuguese'), ('pt-br', 'Brazilian Portuguese'), ('ro', 'Romanian'), ('ru', 'Russian'), ('sk', 'Slovak'), ('sl', 'Slovenian'), ('sq', 'Albanian'), ('sr', 'Serbian'), ('sr-latn', 'Serbian Latin'), ('sv', 'Swedish'), ('sw', 'Swahili'), ('ta', 'Tamil'), ('te', 'Telugu'), ('th', 'Thai'), ('tr', 'Turkish'), ('tt', 'Tatar'), ('udm', 'Udmurt'), ('uk', 'Ukrainian'), ('ur', 'Urdu'), ('vi', 'Vietnamese'), ('zh-hans', 'Simplified Chinese'), ('zh-hant', 'Traditional Chinese')] LANGUAGES_BIDI = ['he', 'ar', 'fa', 'ur'] LANGUAGE_CODE = 'es-ve' LANGUAGE_COOKIE_AGE = None LANGUAGE_COOKIE_DOMAIN = None LANGUAGE_COOKIE_NAME = 'django_language' LANGUAGE_COOKIE_PATH = '/' LOCALE_PATHS = [] LOGGING = {} LOGGING_CONFIG = 'logging.config.dictConfig' LOGIN_REDIRECT_URL = '/accounts/profile/' LOGIN_URL = '/accounts/login/' LOGOUT_REDIRECT_URL = None MANAGERS = [] MEDIA_ROOT = '/home/gabo/Laboratorio 3/jager_server/media' MEDIA_URL = '/media/' MESSAGE_STORAGE = 'django.contrib.messages.storage.fallback.FallbackStorage' MIDDLEWARE = ['django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware'] MIGRATION_MODULES = {} MONTH_DAY_FORMAT = 'F j' NUMBER_GROUPING = 0 OAUTH2_PROVIDER = {'ACCESS_TOKEN_EXPIRE_SECONDS': '****'} PASSWORD_HASHERS = '****' PASSWORD_RESET_TIMEOUT_DAYS = '****' PREPEND_WWW = False PROJECT_DIR = '/home/gabo/Laboratorio 3/jager_server/jager_server' REST_FRAMEWORK = {'DEFAULT_PERMISSION_CLASSES': ('rest_framework.permissions.IsAuthenticated',), 'DEFAULT_AUTHENTICATION_CLASSES': ('oauth2_provider.contrib.rest_framework.OAuth2Authentication', 'rest_framework_social_oauth2.authentication.SocialAuthentication', 'rest_framework.authentication.TokenAuthentication')} ROOT_URLCONF = 'jager_server.urls' SECRET_KEY = '****' SECURE_BROWSER_XSS_FILTER = False SECURE_CONTENT_TYPE_NOSNIFF = False SECURE_HSTS_INCLUDE_SUBDOMAINS = False SECURE_HSTS_PRELOAD = False SECURE_HSTS_SECONDS = 0 SECURE_PROXY_SSL_HEADER = None SECURE_REDIRECT_EXEMPT = [] SECURE_SSL_HOST = None SECURE_SSL_REDIRECT = False SERVER_EMAIL = 'root@localhost' SESSION_CACHE_ALIAS = 'default' SESSION_COOKIE_AGE = 1209600 SESSION_COOKIE_DOMAIN = None SESSION_COOKIE_HTTPONLY = True SESSION_COOKIE_NAME = 'sessionid' SESSION_COOKIE_PATH = '/' SESSION_COOKIE_SAMESITE = 'Lax' SESSION_COOKIE_SECURE = False SESSION_ENGINE = 'django.contrib.sessions.backends.db' SESSION_EXPIRE_AT_BROWSER_CLOSE = False SESSION_FILE_PATH = None SESSION_SAVE_EVERY_REQUEST = False SESSION_SERIALIZER = 'django.contrib.sessions.serializers.JSONSerializer' SETTINGS_MODULE = 'jager_server.settings' SHORT_DATETIME_FORMAT = 'm/d/Y P' SHORT_DATE_FORMAT = 'm/d/Y' SIGNING_BACKEND = 'django.core.signing.TimestampSigner' SILENCED_SYSTEM_CHECKS = [] SOCIAL_AUTH_GOOGLE_OAUTH2_KEY = '****' SOCIAL_AUTH_GOOGLE_OAUTH2_SCOPE = ['https://www.googleapis.com/auth/userinfo.email', 'https://www.googleapis.com/auth/userinfo.profile'] SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET = '****' STATICFILES_DIRS = [] STATICFILES_FINDERS = ['django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder'] STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.StaticFilesStorage' STATIC_ROOT = '/home/gabo/Laboratorio 3/jager_server/jager_server/static' STATIC_URL = '/static/' TEMPLATES = [{'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [], 'APP_DIRS': True, 'OPTIONS': {'context_processors': ['django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', 'social_django.context_processors.backends', 'social_django.context_processors.login_redirect']}}] TEST_NON_SERIALIZED_APPS = [] TEST_RUNNER = 'django.test.runner.DiscoverRunner' THOUSAND_SEPARATOR = ',' TIME_FORMAT = 'P' TIME_INPUT_FORMATS = ['%H:%M:%S', '%H:%M:%S.%f', '%H:%M'] TIME_ZONE = 'UTC' USE_I18N = True USE_L10N = True USE_THOUSAND_SEPARATOR = False USE_TZ = True USE_X_FORWARDED_HOST = False USE_X_FORWARDED_PORT = False WSGI_APPLICATION = 'jager_server.wsgi.application' X_FRAME_OPTIONS = 'SAMEORIGIN' YEAR_MONTH_FORMAT = 'F Y'
You're seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard page generated by the handler for this status code.