From 55b9d197f023067470f8769615a83e1a11df53ba Mon Sep 17 00:00:00 2001 From: HemangChothani <50404902+HemangChothani@users.noreply.github.com> Date: Fri, 29 Jan 2021 13:50:33 -0500 Subject: [PATCH] fix: add project env in readme file (#586) --- examples/from-scratch/README.md | 18 +++++++++++++++--- examples/healthchecks/README.md | 23 ++++++++++++----------- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/examples/from-scratch/README.md b/examples/from-scratch/README.md index fd0439a511..9e5ab47921 100644 --- a/examples/from-scratch/README.md +++ b/examples/from-scratch/README.md @@ -4,7 +4,18 @@ This example shows how to use django-spanner for Cloud Spanner as a backend data *NOTE:* Use the version of python-spanner-django that corresponds to your version of Django. For example, python-spanner-django 2.2.x works with Django 2.2.y. (This is the only supported version at this time.) -### Walkthrough the introduction to Django +### Table of contents +- [Install django-spanner](#install-django-spanner) +- [Ensure you have a Cloud Spanner database already created](#ensure-you-have-a-cloud-spanner-database-already-created) +- [Follow the tutorial](#follow-the-tutorial) +- [Update your settings.py file to use django-spanner](#update-your-settings.py-file-to-use-django-spanner) +- [Set credentials and project environment variables](#Set-credentials-and-project-environment-variables) +- [Apply the migrations](#apply-the-migrations) +- [Now run your server](#now-run-your-server) +- [Create an Django admin user](#create-an-django-admin-user) +- [Login as admin](#login-as-admin) +- [Comprehensive hands-on guide](#comprehensive-hands-on-guide) +- [References](#references) ### Install django-spanner To install from PyPI: @@ -74,10 +85,11 @@ DATABASES = { } ``` -### Set Google Application Default Credentials to the environment -You'll need to download a service account JSON key file and point to it using an environment variable: +### Set credentials and project environment variables +You'll need to download a service account JSON key file and point to it using an environment variable: ```shell export GOOGLE_APPLICATION_CREDENTIALS=/path/to/keyfile.json +export GOOGLE_CLOUD_PROJECT=gcloud_project ``` ### Apply the migrations diff --git a/examples/healthchecks/README.md b/examples/healthchecks/README.md index 7685b2fe34..817f0c01fa 100644 --- a/examples/healthchecks/README.md +++ b/examples/healthchecks/README.md @@ -9,7 +9,7 @@ This example shows how to use django-spanner for Cloud Spanner as a backend data - [Clone django-spanner](#clone-django-spanner) - [Install django-spanner in the virtual-env](#install-django-spanner-in-the-virtual-env) - [Ensure you have a Cloud Spanner database already created](#ensure-you-have-a-Cloud-Spanner-database-already-created) -- [Set Google Application Default Credentials to the environment](#Set-Google-Application-Default-Credentials-to-the-environment) +- [Set credentials and project environment variables](#Set-credentials-and-project-environment-variables) - [Update local_settings.py](#update-local_settings.py) - [Run the server](#run-the-server) - [Apply the migrations](#apply-the-migrations) @@ -56,11 +56,12 @@ now install django-spanner using the path you obtained in [Clone django-spanner] If you haven't already, please follow the steps to install [Cloud Spanner](https://cloud.google.com/spanner/docs/getting-started/set-up), or visit this [codelab](https://opencensus.io/codelabs/spanner/#0) -### Set Google Application Default Credentials to the environment -You'll need to download a service account JSON keyfile and point to it using an environment variable: +### Set credentials and project environment variables +You'll need to download a service account JSON keyfile and point to it using an environment variable: ```shell export GOOGLE_APPLICATION_CREDENTIALS=/path/to/keyfile.json +export GOOGLE_CLOUD_PROJECT=gcloud_project ``` ### Update local_settings.py @@ -70,23 +71,23 @@ After we have a Cloud Spanner database created, we'll need a few variables: * Database name aka DisplayName -*NOTE:* Healthchecks's `local_settings.py` overrides the default settings +*NOTE:* Healthchecks's `local_settings.py` overrides the default settings mentioned in `settings.py`. There are two ways to edit settings file: -1. You can edit the file `hc/settings.py` to: - +1. You can edit the file `hc/settings.py` to: + a) Add `django_spanner` as the first entry to `INSTALLED_APPS`: - + ```python INSTALLED_APPS = [ 'django_spanner', # Must be listed first. ... ] ``` - + b) Edit `DATABASES` into the following: - + ```python DATABASES = { 'default': { @@ -102,7 +103,7 @@ There are two ways to edit settings file: a) The `INSTALLED_APPS` MUST be copied from hc/settings.py to hc/local_settings.py and add `django_spanner` as the first entry to `INSTALLED_APPS`: - + ```python INSTALLED_APPS = [ 'django_spanner', # Must be listed first. @@ -111,7 +112,7 @@ There are two ways to edit settings file: ``` b) Add or Edit `DATABASES` into the following: - + ```python DATABASES = { 'default': {