Skip to content

Commit

Permalink
fix: add project env in readme file (#586)
Browse files Browse the repository at this point in the history
  • Loading branch information
HemangChothani committed Jan 29, 2021
1 parent 8441edc commit 55b9d19
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 14 deletions.
18 changes: 15 additions & 3 deletions examples/from-scratch/README.md
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
23 changes: 12 additions & 11 deletions examples/healthchecks/README.md
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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': {
Expand All @@ -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.
Expand All @@ -111,7 +112,7 @@ There are two ways to edit settings file:
```

b) Add or Edit `DATABASES` into the following:

```python
DATABASES = {
'default': {
Expand Down

0 comments on commit 55b9d19

Please sign in to comment.