>
>
> web_dir = 
> (os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), 
> os.pardir)))
> src_dir = (os.path.abspath(os.path.join(web_dir, os.pardir)))
> lib_dir = os.path.join(src_dir, "lib")
> """
> """
> sys.path.append(lib_dir)
>
> # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
> BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
>
> # Quick-start development settings - unsuitable for production
> # See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/
>
> # SECURITY WARNING: keep the secret key used in production secret!
> SECRET_KEY = os.environ['SECRET_KEY']
>
> ACME_CHALLENGE_URL_SLUG = ""
> ACME_CHALLENGE_TEMPLATE_CONTENT = "" \
>                                   "."
>
> # SECURITY WARNING: don't run with debug turned on in production!
> DEBUG = os.environ['DEBUG'] == 'True'
>
> PROJECT_DIR = os.path.dirname(os.path.abspath(__file__))
>
> ALLOWED_HOSTS = ['*']
>
> # Application definition
>
> INSTALLED_APPS = [
>     'django.contrib.admin',
>     'django.contrib.auth',
>     'django.contrib.contenttypes',
>     'django.contrib.sessions',
>     'django.contrib.messages',
>     'django.contrib.staticfiles',
>     'rest_framework',
>     'acme_challenge',
>     'rest_framework.authtoken',
>     'corsheaders',
>     'django_countries',
>     'rest_registration',
>     'apps.users',
>     'apps.api_lib',
> ]
>
>
> MIDDLEWARE = [
>     'corsheaders.middleware.CorsMiddleware',
>     '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',
> ]
>
> CORS_ORIGIN_WHITELIST = (
>     '......',
>     '......',
>     'localhost:8000',
>     'localhost:4200'
> )
>
> ROOT_URLCONF = 'app.urls'
>
> 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',
>             ],
>         },
>     },
> ]
>
> WSGI_APPLICATION = 'app.wsgi.application'
>
> # Database
> # https://docs.djangoproject.com/en/1.11/ref/settings/#databases
>
>
>
> DATABASES = {
>     'default': {
>         'ENGINE': 'django.db.backends.postgresql',
>         'HOST': os.environ['DB_HOST'],
>         'PORT': os.environ['DB_PORT'],
>         'NAME': os.environ['DB_NAME'],
>         'USER': os.environ['DB_USER'],
>         'PASSWORD': os.environ['DB_PASSWORD'] or ''
>     }
> }
>
> # Password validation
> # 
> https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators
>
> AUTH_PASSWORD_VALIDATORS = [
>     {
>         'NAME': 
> 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
>     },
>     {
>         'NAME': 
> 'django.contrib.auth.password_validation.MinimumLengthValidator',
>     },
>     {
>         'NAME': 
> 'django.contrib.auth.password_validation.CommonPasswordValidator',
>     },
>     {
>         'NAME': 
> 'django.contrib.auth.password_validation.NumericPasswordValidator',
>     },
> ]
>
> # Internationalization
> # https://docs.djangoproject.com/en/1.11/topics/i18n/
>
> LANGUAGE_CODE = 'en-us'
>
> TIME_ZONE = 'UTC'
>
> USE_I18N = True
>
> USE_L10N = True
>
> USE_TZ = True
>
> # Static files (CSS, JavaScript, Images)
> # https://docs.djangoproject.com/en/1.11/howto/static-files/
>
> STATIC_URL = os.environ['STATIC_URL']  # /static/ if DEBUG else Google Cloud 
> bucket url
>
> # collectstatic directory (located OUTSIDE the base directory)
> # TODO: configure the name and path to your static bucket directory (where 
> collectstatic will copy to)
> STATIC_ROOT = os.path.join(os.path.dirname(BASE_DIR), '......')
>
> STATICFILES_DIRS = [
>     # TODO: configure the name and path to your development static directory
>     os.path.join(BASE_DIR, 'static'),  # static directory (in the top level 
> directory) for local testing
> ]
>
> PASSWORD_HASHERS = [
>     'django.contrib.auth.hashers.PBKDF2PasswordHasher',
>     'django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher',
>     'django.contrib.auth.hashers.Argon2PasswordHasher',
>     'django.contrib.auth.hashers.BCryptSHA256PasswordHasher',
> ]
>
> REST_FRAMEWORK = {
>     'DEFAULT_AUTHENTICATION_CLASSES': (
>         'rest_framework.authentication.TokenAuthentication',
>     ),
> }
>
> REST_FRAMEWORK_TOKEN_EXPIRE_HOURS = 24
>
> AUTH_USER_MODEL = "users.user"
>
> REST_REGISTRATION = {
>     'REGISTER_VERIFICATION_URL': 'https://www.....verify-user/',
>     'RESET_PASSWORD_VERIFICATION_URL': 'https://www......./reset-password/',
>     'REGISTER_EMAIL_VERIFICATION_URL': 'https://www....../verify-email/',
>     'VERIFICATION_FROM_EMAIL': 'no-reply@......',
> }
>
> EMAIL_HOST = os.environ['SMTP_HOST']
> EMAIL_HOST_USER = os.environ['SMTP_USER']
> EMAIL_HOST_PASSWORD = os.environ['SMTP_PASSWORD']
>
> APPEND_SLASH = True
>
>




On Friday, 12 October 2018 13:50:11 UTC+2, Lukas Elsner wrote:
>
>
> I have a Django application with Google Cloud SQL Postgres Database 
> deployed to App Engine Flex at the moment.
>
> I am trying to migrate it from Flex to Standard.
>
> Everything seems to work, except the Database connection. The 
> Documentation is not quite clear about it.
>
> For Flex I need to use:
>
>>
>> beta_settings:
>>   cloud_sql_instances: .......
>>
>>
> in app.yaml.
>
>
> In Standard, I tried with and without, but I always get a connection 
> refused.
>
> Did anyone get this working?
>
>  
>
>
>
>
>
> --------------------------------------------------------------------------------
>
> Flex:
>
>> runtime: python
>>
>> env: flex
>>
>> manual_scaling:
>>   instances: 1
>>
>> resources:
>>   cpu: 0.2
>>   memory_gb: 0.5
>>   disk_size_gb: 10
>>
>> health_check:
>>  enable_health_check: False
>>
>> runtime_config:
>>   python_version: 3
>>
>> entrypoint: web/run.sh
>>
>> env_variables:
>>   SECRET_KEY: '___DJANGO_SECRET_KEY___'
>>   DEBUG: 'True' # always False for deployment
>>   SMTP_HOST: "___SMTP_HOST___"
>>   SMTP_USER: "___SMTP_USER___"
>>   SMTP_PASSWORD: "___SMTP_PASSWORD___"
>>   DB_HOST: '/cloudsql/.........................'
>>   DB_PORT: '5432' # PostgreSQL port
>>   DB_NAME: '......'
>>   DB_USER: '........'
>>   DB_PASSWORD: '___DB_PASSWORD___'
>>   STATIC_URL: 
>> 'https://storage.googleapis.com/................-backend-static-files/static/'
>>  # this is the url that you sync static files to
>>
>> handlers:
>> - url: /.*
>>   script: auto
>>   secure: always
>>
>> beta_settings:
>>   cloud_sql_instances: .....................
>>
>>  
>
>
> Standard:
>
>> runtime: python37
>>
>> entrypoint: web/run.sh
>>
>> env_variables:
>>   SECRET_KEY: '___DJANGO_SECRET_KEY___'
>>   DEBUG: 'True' # always False for deployment
>>   SMTP_HOST: "___SMTP_HOST___"
>>   SMTP_USER: "___SMTP_USER___"
>>   SMTP_PASSWORD: "___SMTP_PASSWORD___"
>>   DB_HOST: '/cloudsql/.........................'  DB_PORT: '5432' # 
>> PostgreSQL port
>>
>>   DB_NAME: '......'
>>   DB_USER: '........'
>>
>> DB_PASSWORD: '___DB_PASSWORD___'
>>
>>   STATIC_URL: 
>> 'https://storage.googleapis.com/................-backend-static-files/static/'
>>  # this is the url that you sync static files to 
>>
>>  
>>
>> beta_settings:
>>>
>>>   cloud_sql_instances: .....................
>>>
>>>  
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-appengine+unsubscr...@googlegroups.com.
To post to this group, send email to google-appengine@googlegroups.com.
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-appengine/2774764e-045a-42e2-be17-bd04f3c2fd02%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to