Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions azuresite/production.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,15 @@
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')

# DBHOST is only the server name, not the full URL
hostname = os.environ['DBHOST']

# Configure Postgres database; the full username is username@servername,
# which we construct using the DBHOST value.
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': os.environ['DBNAME'],
'HOST': hostname + ".postgres.database.azure.com",
'USER': os.environ['DBUSER'] + "@" + hostname,
'PASSWORD': os.environ['DBPASS']
'HOST': os.environ['DBHOST'],
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@raahmed Verify how the tutorial is written for this section. If we are stating to have DBHOST with severname and fully qualified name then we should revert back to 'HOST': hostname + ".postgres.database.azure.com" . Validate this with the tutorial please

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The value of 'HOST' in the JSON output is the full name. To avoid confusion, I've changed the sample/tutorial so that it is a clear-cut copy-paste. Users get very confused and fail when they have to update the string.

'USER': os.environ['DBUSER'],
'PASSWORD': os.environ['DBPASS'],
'OPTIONS': {'sslmode': 'require'}
}
}