Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 65d2e9d

Browse filesBrowse files
fix: fix healthchecks app tutorial (#574)
Co-authored-by: Alex <7764119+AVaksman@users.noreply.github.com>
1 parent 3cb51a6 commit 65d2e9d
Copy full SHA for 65d2e9d

File tree

Expand file treeCollapse file tree

1 file changed

+66
-27
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+66
-27
lines changed

‎examples/healthchecks/README.md

Copy file name to clipboardExpand all lines: examples/healthchecks/README.md
+66-27Lines changed: 66 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@
22

33
This example shows how to use django-spanner for Cloud Spanner as a backend database for [https://healthchecks.io](https://healthchecks.io)
44

5+
*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.)
6+
57
### Table of contents
68
- [Install healthchecks](#install-healthchecks)
79
- [Clone django-spanner](#clone-django-spanner)
810
- [Install django-spanner in the virtual-env](#install-django-spanner-in-the-virtual-env)
911
- [Ensure you have a Cloud Spanner database already created](#ensure-you-have-a-Cloud-Spanner-database-already-created)
12+
- [Set Google Application Default Credentials to the environment](#Set-Google-Application-Default-Credentials-to-the-environment)
1013
- [Update local_settings.py](#update-local_settings.py)
1114
- [Run the server](#run-the-server)
1215
- [Apply the migrations](#apply-the-migrations)
@@ -23,16 +26,16 @@ Open a fresh terminal, and go to a location that isn't a parent directory of whe
2326
For example we can go to our $HOME/Desktop
2427
```shell
2528
cd $HOME/Desktop
26-
git clone https://github.com/googleapis/django-spanner
29+
git clone https://github.com/googleapis/python-spanner-django
2730
```
2831

2932
Note the full path of where django-spanner has been cloned into, for example
3033
```shell
31-
DJANGO_SPANNER_CODE_DIR=$Desktop/django-spanner
34+
DJANGO_SPANNER_CODE_DIR=$Desktop/python-spanner-django
3235
```
3336
or add it to your environment, perhaps like this
3437
```shell
35-
export DJANGO_SPANNER_CODE_DIR=$Desktop/django-spanner
38+
export DJANGO_SPANNER_CODE_DIR=$Desktop/python-spanner-django
3639
```
3740

3841
### Install django-spanner in the virtual-env
@@ -53,42 +56,78 @@ now install django-spanner using the path you obtained in [Clone django-spanner]
5356
If you haven't already, please follow the steps to install [Cloud Spanner](https://cloud.google.com/spanner/docs/getting-started/set-up),
5457
or visit this [codelab](https://opencensus.io/codelabs/spanner/#0)
5558

56-
**You'll need to ensure that your Google Application Default Credentials are properly downloaded and saved in your environment.**
59+
### Set Google Application Default Credentials to the environment
60+
You'll need to download a service account JSON keyfile and point to it using an environment variable:
61+
62+
```shell
63+
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/keyfile.json
64+
```
5765

5866
### Update local_settings.py
5967
After we have a Cloud Spanner database created, we'll need a few variables:
6068
* ProjectID
6169
* Instance name
6270
* Database name aka DisplayName
6371

64-
Once in, please edit the file `hc/local_settings.py` to:
65-
a) Add `django_spanner` as the first entry to `INSTALLED_APPS`
66-
```python
67-
INSTALLED_APPS = [
68-
'django_spanner', # Must be listed first.
69-
...
70-
]
71-
```
72-
**The rest of the apps MUST be copied from hc/settings.py**
73-
7472

75-
b) Edit `DATABASES` into the following:
76-
```python
77-
DATABASES = {
78-
'default': {
79-
'ENGINE': 'django_spanner',
80-
'PROJECT': PROJECT_ID,
81-
'INSTANCE': SPANNER_INSTANCE,
82-
'NAME': SPANNER_DATABASE_NAME,
83-
}
84-
}
85-
```
73+
*NOTE:* Healthchecks's `local_settings.py` overrides the default settings
74+
mentioned in `settings.py`.
75+
76+
There are two ways to edit settings file:
77+
1. You can edit the file `hc/settings.py` to:
78+
79+
a) Add `django_spanner` as the first entry to `INSTALLED_APPS`:
80+
81+
```python
82+
INSTALLED_APPS = [
83+
'django_spanner', # Must be listed first.
84+
...
85+
]
86+
```
87+
88+
b) Edit `DATABASES` into the following:
89+
90+
```python
91+
DATABASES = {
92+
'default': {
93+
'ENGINE': 'django_spanner',
94+
'PROJECT': PROJECT_ID,
95+
'INSTANCE': SPANNER_INSTANCE,
96+
'NAME': SPANNER_DATABASE_NAME,
97+
}
98+
}
99+
```
100+
101+
2. You can edit the file `hc/local_settings.py` to:
102+
103+
a) The `INSTALLED_APPS` MUST be copied from hc/settings.py to hc/local_settings.py
104+
and add `django_spanner` as the first entry to `INSTALLED_APPS`:
105+
106+
```python
107+
INSTALLED_APPS = [
108+
'django_spanner', # Must be listed first.
109+
...
110+
]
111+
```
112+
113+
b) Add or Edit `DATABASES` into the following:
114+
115+
```python
116+
DATABASES = {
117+
'default': {
118+
'ENGINE': 'django_spanner',
119+
'PROJECT': PROJECT_ID,
120+
'INSTANCE': SPANNER_INSTANCE,
121+
'NAME': SPANNER_DATABASE_NAME,
122+
}
123+
}
124+
```
86125

87126
and for example here is a filled in database where:
88127

89128
* `PROJECT_ID`: spanner-appdev
90-
* INSTANCE: instance
91-
* NAME: `healthchecks_db`
129+
* `INSTANCE`: instance
130+
* `NAME`: healthchecks_db
92131

93132
which when filled out, will look like this
94133

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.