This is a demo of a Django app using Google Datastore via django-gcloud-connectors. Read the dev.to post.
🚨 Before deploying: ensure the project you deploy to has Cloud Firestore in Datastore mode enabled, and deploy this service to the same region.
-
Copy the
.env_template
file to.env
, and set the template values. -
Set up a Python virtual environment, and install the dependencies:
python -m venv venv source venv/bin/activate pip install -r requirements.txt
-
Run the Django migration commands, and start the server:
./manage.py migrate ./manage.py loaddata sampledata ./manage.py collectstatic --no-input ./manage.py runserver
To use the datastore backend:
- add
django-gcloud-connectors
torequirements.txt
, - add
gcloudc
to the top ofINSTALLED_APPS
insettings.py
, - add
gcloudc.db.backends.datastore
as anENGINE
inDATABASES
insettings.py
.
When testing your app, set DEBUG=True
in your settings.py
or .env
, and when encountering 400 no matching index found
errors:
-
append the recommended index to
index.yaml
, -
run
gcloud datastore indexes create index.yaml
, -
wait for the index(es) to be ready:
gcloud datastore indexes list --format "value(state,kind)"
For more details, see the django-gcloud-connectors project docs.
This project additionally makes use of:
- Google Secret Manager,
- Google Cloud Build,
- Google Cloud Storages (via
django-storages[google]
), and - Google Cloud Run.
Deployment details can be found in .gcloud/
, and more details about the Django-specific use of the Google components can be found in the django-demo-app-unicodex
docs.
mewgram uses Robohash set #4 for it's identicons. Robohash is available as a Python package.
While this app does use Datastore, the major limitation it faces is due to indexes.
The indexes defined in index.yaml
is sufficient to navigate the entire app front end, and base admin pages, but not for:
- sorting in the admin,
- running Hypothesis tests.