OperationalError at /login/auth0

I have a Django application and followed the “getting started” guide to implement my Auth0 functionality. It works just fine locally but I ran into some issues when I tried to deploy it using Google Cloud App Engine.
I’m a total newbie at both Django and Auth0 so any help at all would be greatly appreciated <3

OperationalError at /login/auth0

attempt to write a readonly database

Request Method: GET
Request URL: https://<MY_URL>/login/auth0

Django Version: 2.2.5
Python Version: 3.7.4
Installed Applications:
[‘django.contrib.admin’,
‘django.contrib.auth’,
‘django.contrib.contenttypes’,
‘django.contrib.sessions’,
‘django.contrib.messages’,
‘django.contrib.staticfiles’,
‘social_django’,
‘Dashboard’]
Installed Middleware:
[‘django.middleware.security.SecurityMiddleware’,
‘django.contrib.sessions.middleware.SessionMiddleware’,
‘django.middleware.common.CommonMiddleware’,
‘django.middleware.csrf.CsrfViewMiddleware’,
‘django.contrib.auth.middleware.AuthenticationMiddleware’,
‘django.contrib.messages.middleware.MessageMiddleware’,
‘django.middleware.clickjacking.XFrameOptionsMiddleware’]

Traceback:

File “/env/lib/python3.7/site-packages/django/db/backends/utils.py” in _execute
84. return self.cursor.execute(sql, params)

File “/env/lib/python3.7/site-packages/django/db/backends/sqlite3/base.py” in execute
383. return Database.Cursor.execute(self, query, params)

The above exception (attempt to write a readonly database) was the direct cause of the following exception:

File “/env/lib/python3.7/site-packages/django/core/handlers/exception.py” in inner
34. response = get_response(request)

File “/env/lib/python3.7/site-packages/django/utils/deprecation.py” in call
96. response = self.process_response(request, response)

File “/env/lib/python3.7/site-packages/django/contrib/sessions/middleware.py” in process_response
58. request.session.save()

File “/env/lib/python3.7/site-packages/django/contrib/sessions/backends/db.py” in save
81. return self.create()

File “/env/lib/python3.7/site-packages/django/contrib/sessions/backends/db.py” in create
55. self.save(must_create=True)

File “/env/lib/python3.7/site-packages/django/contrib/sessions/backends/db.py” in save
87. obj.save(force_insert=must_create, force_update=not must_create, using=using)

File “/env/lib/python3.7/site-packages/django/db/models/base.py” in save
741. force_update=force_update, update_fields=update_fields)

File “/env/lib/python3.7/site-packages/django/db/models/base.py” in save_base
779. force_update, using, update_fields,

File “/env/lib/python3.7/site-packages/django/db/models/base.py” in _save_table
870. result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)

File “/env/lib/python3.7/site-packages/django/db/models/base.py” in _do_insert
908. using=using, raw=raw)

File “/env/lib/python3.7/site-packages/django/db/models/manager.py” in manager_method
82. return getattr(self.get_queryset(), name)(*args, **kwargs)

File “/env/lib/python3.7/site-packages/django/db/models/query.py” in _insert
1186. return query.get_compiler(using=using).execute_sql(return_id)

File “/env/lib/python3.7/site-packages/django/db/models/sql/compiler.py” in execute_sql
1335. cursor.execute(sql, params)

File “/env/lib/python3.7/site-packages/django/db/backends/utils.py” in execute
99. return super().execute(sql, params)

File “/env/lib/python3.7/site-packages/django/db/backends/utils.py” in execute
67. return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)

File “/env/lib/python3.7/site-packages/django/db/backends/utils.py” in _execute_with_wrappers
76. return executor(sql, params, many, context)

File “/env/lib/python3.7/site-packages/django/db/backends/utils.py” in _execute
84. return self.cursor.execute(sql, params)

File “/env/lib/python3.7/site-packages/django/db/utils.py” in exit
89. raise dj_exc_value.with_traceback(traceback) from exc_value

File “/env/lib/python3.7/site-packages/django/db/backends/utils.py” in _execute
84. return self.cursor.execute(sql, params)

File “/env/lib/python3.7/site-packages/django/db/backends/sqlite3/base.py” in execute
383. return Database.Cursor.execute(self, query, params)

Exception Type: OperationalError at /login/auth0
Exception Value: attempt to write a readonly database

1 Like

This looks like a django specific error. When I searched for that error I got this stackoverflow thread sqlite - Attempt to write a readonly database - Django w/ SELinux error - Stack Overflow

Important bit from the accepted answer there

You have to add writing rights to the directory in which your sqlite database is stored. So running chmod 664 /srv/mysite should help

chmod 664 /srv/mysite should be chmod 664 /your/djangowebstie