3

Someone flagged this as a duplicate - it is not a duplicate of the question they linked to for the following reasons. First I’m not getting 404 errors for every url. I get some templates and not others, I get all of the templates at the top level of the templates folder, just not those in the subdirectories. Also it gives 500 errors not 404 errors, which is a different category of error.

I've been trying to put a django(2.1) (python3) application on google's flexible app engine and have run into the following problem:

The application does not render any templates that are in subdirecties of the templates folder, it gives 500 errors. I've been looking at the tails of the logs via gcloud console and within the admin interface and I don't see anything useful.

My app.yaml is:

runtime: python
# api_version: 1

env: flex
entrypoint: gunicorn -b :$PORT MyApp.MyApp.wsgi
runtime_config:
    python_version: 3

manual_scaling:
  instances: 1
resources:
  cpu: 1
  memory_gb: 0.5
  disk_size_gb: 10

env_variables:
  SECRET_KEY: 'key-here'
  DEBUG: 'False'
  DB_HOST: '/cloudsql/instance:region:instance'
  DB_PORT: '5432'
  DB_NAME: 'instance'
  DB_USER: 'postgres'
  DB_PASSWORD: 'db-password'
  STATIC_URL: 'https://storage.googleapis.com/bucket-name/static/'

beta_settings:
  cloud_sql_instances: 'instance:region:instance'

My template folders settings: BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(file)))

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR, 'templates'),
                 os.path.join(BASE_DIR, 'templates', 'subdir'),
                 os.path.join(BASE_DIR, 'templates', 'subdir', 'othersubdir'),

etc.

I'm really stumped. Any advice or feedback on where to get more detailed error logs, or what the problem might be would be greatly appreciated - thanks!!!

2 Answers2

0

Try something more direct, like:

TEMPLATE_DIRS = (os.path.join(os.path.dirname(__file__), 'templates'),)
TEMPLATE_DIRS += (os.path.join(os.path.dirname(__file__), 'templates/subdir'),)
TEMPLATE_DIRS += (os.path.join(os.path.dirname(__file__), 'templates/subdir/othersubdir'),)

os.path.dirname(__file__) is the location of settings.py, so everything is relative from there.

GAEfan
  • 11,244
  • 2
  • 17
  • 33
0

Maybe before starting over again you can see some more specific errors on Stackdriver Logs, you can filter the logs by the resource using the filters and maybe you'll be able to see more details about the errors on you GAE Application.

Anyway... if you already started over again, maybe you can use this example project as a reference to see all the configurations needed and the implementation

chinoche
  • 335
  • 1
  • 8