-
Daniel Bessey authored3ab26920
Setup a virtual environment
Install PostgreSQL
Install dependencies: .. code-block:: bash
sudo apt instal postgresql postgresql-server-dev-10
Change to user 'postgres', login to postgresql prompt and (if necessary) set password: .. code-block:: bash
sudo -u postgres -i psql /password password
Yeah, there's a space before CREATE DATABASE...
Create database and chech it is created with: .. code-block:: bash
- CREATE DATABASE pount-db;
- /l
Alternative: .. code-block:: bash
- psql
- CREATE USER username;
/du /q psql pount-db
GRANT ALL PRIVILEGES ON DATABASE pount-db TO username;
Elasticsearch
Elasticsearch is used for indexing and searching. The ICU plugin is used for extended Unicode support and must be installed.
When models are updated, data must be reindexed in Elasticsearch. This process can possibly take time as many related objects may be involved. Therefore, it is advised that this reindexing process is performed asynchronously. Pount uses Celery and Rabbitmq for these asynchronous tasks.
When running unittests, we don't want this reindexing taking place. Therefore we use a DummySignalProcessor class
defined in pount.settings.unittest
:
ELASTICSEARCH_DSL_SIGNAL_PROCESSOR = "pount.apps.api.signals.DummySignalProcessor"
- For local development the
docker-compose.yml
file provides services for: -
- Elasticsearch
- Rabbitmq
- Postgresql
The following environment variables are expected for Rabbitmq:
Start the Celery worker:
To reindex data in Elasticsearch
Create Django project
Create requirements file: .. literalinclude:: requirements.txt
Install requirements. Please make sure your venv is activated first ! .. code-block:: bash
pip install -r requirements.txt
Create a Django project, and create an app in it: .. code-block:: bash
django-admin startproject elasticsearchproject cd elasticsearchproject python manage.py startapp elasticsearchapp
Edit elasticsearchapp/models.py. Edit elasticsearchapp/admin.py. Edit settings.py to add 'elasticsearchapp' to INSTALLED_APPS.
Create elasticsearchapp/search.py