0

I have hosted Django app using App Engine standard environment. When I try to login, it gives me 'attempt to write a readonly database' error . I have added URL to ALLOWED HOSTS and added in admin credentials in DATABASE in settings.py. Everything else works as intended.

app.yaml

# [START django_app]
runtime: python37
service: hellotest1

handlers:
# This configures Google App Engine to serve the files in the app's static
# directory.
- url: /static
  static_dir: static/
# This handler routes all requests not caught above to your main app. It is
# required when static routes are defined, but can be omitted (along with
# the entire handlers section) when there are no static files defined.
- url: /.*
  script: auto
# [END django_app]

settings.py - DATABASES and ALLOWED_HOSTS

ALLOWED_HOSTS = ['url']

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
        'USER': 'admin',
        'PASSWORD': 'admin',

    }
}
russianmax
  • 127
  • 1
  • 8

1 Answers1

0

The filesystem on AppEngine instances is read-only (except for the /tmp directory iirc). Hoever even if it would be writable, using SQLite won't work in a long term for this scenario, because when you will deploy a new version of your application, a new instance is spawned, but your database (file) stays on the old instance only. This would be problem in case you would have more than one instance too - each of them would need to have its own db. It won't simply work this way, you need to create an instance of Postgres or MySQL.

yedpodtrzitko
  • 8,323
  • 2
  • 36
  • 39