You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -27,75 +27,124 @@ A complete list of existing parameters is provided in the file `optimap/.env.exa
27
27
28
28
## Run with Docker
29
29
30
+
The project is containerized using Docker, with services defined in `docker-compose.yml`. To start all services, run:
31
+
30
32
```bash
31
33
docker-compose up
34
+
```
35
+
36
+
### Initial Setup
37
+
38
+
After starting the containers, apply database migrations:
32
39
40
+
```bash
33
41
# run migrations, in the directory where docker-compose is to resolve the name "web"
34
42
docker-compose run web python manage.py makemigrations
35
43
docker-compose run web python manage.py migrate
36
44
```
37
45
38
-
Now open a browser at <http://localhost:8000/>.
46
+
Now open a browser at <http://localhost:8001/>.
47
+
48
+
#### Services Overview
49
+
50
+
- db: Runs a PostgreSQL database with PostGIS extensions. Data is persisted in a Docker volume named db_data.
51
+
- app: Python-based app serving HTTP requests.
52
+
- web: Our primary Django web application.
53
+
- webserver: An Nginx server for serving static files and test files.
54
+
55
+
#### Ports
56
+
57
+
- 5434: Database (PostgreSQL/PostGIS)
58
+
- 8002: App (Python HTTP server)
59
+
- 8001: Web application (Django server)
60
+
- 8080: Webserver (Nginx)
39
61
40
62
## Development
41
63
42
-
### Test data
64
+
### Test Data
65
+
66
+
The folder `/fixtures` contains some test data, which can be used to populate the database during development. These data are provided either as SQL commands for insertion into the database or as database dumps that can be loaded using [`django-admin`](https://docs.djangoproject.com/en/dev/ref/django-admin/).
67
+
68
+
### Managing Test Data
43
69
44
-
The folder `/fixtures` contains some test data, either as an SQL command to insert into the database, or as a database dump that was created and can be loaded with [`django-admin`](https://docs.djangoproject.com/en/dev/ref/django-admin/).
45
-
[`jq`](https://stedolan.github.io/jq/) is used for pretty-printing of the output.
70
+
#### Creating Test Data Dumps
71
+
72
+
To create a data dump after generating or harvesting test data, use the following command:
46
73
47
74
```bash
48
-
# create dump after creating/harvesting test data:
If you want to create more testdata manually, copy and paste the existing records or add more records in the admin backend (preferred).
56
-
A useful tool for creating sensible geometries is <https://wktmap.com/>.
86
+
#### Adding New Test Data
87
+
88
+
If additional test data is required, you can:
89
+
90
+
- Copy and paste existing records.
91
+
- Add new records via the Django admin interface (preferred method).
92
+
- Manually modify the test data JSON file.
57
93
58
-
### Run locally
94
+
Tools for Geometries
95
+
For creating or editing geometries, consider using the tool [WKTMap](https://wktmap.com/), which provides an easy way to generate Well-Known Text (WKT) representations of spatial data.
59
96
60
-
1. Create a `.env` file based on `.env.example` in the same directory where `settings.py` resides and fill in the configuration settings as needed.
61
-
2. Run the commands below, which use the built-in Python [`venv`](https://docs.python.org/3/library/venv.html), see [this tutorial](https://packaging.python.org/en/latest/guides/installing-using-pip-and-virtual-environments/#create-and-use-virtual-environments) for details
97
+
### Run Locally
98
+
99
+
1. Create a `.env` file based on `.env.example` in the same directory where `settings.py` resides, and fill in the configuration settings as needed.
100
+
2. Run the commands below to set up and run the project locally. This setup uses the built-in Python [`venv`](https://docs.python.org/3/library/venv.html). Refer to [this tutorial](https://packaging.python.org/en/latest/guides/installing-using-pip-and-virtual-environments/#create-and-use-virtual-environments) for more details.
See instructions below for creating a superuser and above for loading test data.
140
+
#### Additional Setup
97
141
98
-
When you are done, deactivate the virtual environment and stop the DB with:
142
+
- Creating a Superuser: Refer to the instructions below to create a superuser for accessing the admin interface.
143
+
- Loading Test Data: Refer to the instructions above to load test data into the database.
144
+
145
+
#### Shutting Down
146
+
147
+
When finished, deactivate the virtual environment and stop the database container:
99
148
100
149
```bash
101
150
deactivate
@@ -119,6 +168,8 @@ OPTIMAP_DEBUG=True
119
168
120
169
Select the Python interpreter created above (`optimap` environment), see instructions at <https://code.visualstudio.com/docs/python/tutorial-django> and <https://code.visualstudio.com/docs/python/environments>.
121
170
171
+
**Note:** The `docker-compose.yml` file is intended for **development**, not deployment.
172
+
122
173
Configuration for debugging with VS Code:
123
174
124
175
```json
@@ -139,6 +190,22 @@ Configuration for debugging with VS Code:
After you enter one, the user will be created immediately. If you leave off the --username or --email options, it will prompt you for those values.
235
+
You will be prompted for a password. After entering one, the superuser will be created immediately. If you omit the --username or --email options, the command will prompt you for those values interactively.
236
+
237
+
Access the admin interface at http://127.0.0.1:8000/admin/.
238
+
239
+
#### Running in a Dockerized App
170
240
171
-
You can acess the admin page at <http://127.0.0.1:8000/admin/>.
241
+
To create a superuser within the containerized application, use the following command:
172
242
173
-
You can also run the command in a containerised app with `docker-compose run web python manage.py ...`.
243
+
```bash
244
+
docker-compose run web python manage.py createsuperuser
245
+
```
246
+
247
+
This will run the same process as above but within the Docker environment. Ensure the container is running and accessible before executing this command
174
248
175
249
## Block Emails/Domains
176
250
@@ -232,6 +306,17 @@ A configuration to debug the test code and also print deprecation warnings:
232
306
},
233
307
"django": true,
234
308
"justMyCode": true
309
+
"name": "Python: Django Test",
310
+
"type": "python",
311
+
"request": "launch",
312
+
"pythonArgs": ["-Wa"],
313
+
"program": "${workspaceFolder}/manage.py",
314
+
"args": ["test", "tests"],
315
+
"env": {
316
+
"OPTIMAP_DEBUG": "True"
317
+
},
318
+
"django": true,
319
+
"justMyCode": true
235
320
}
236
321
```
237
322
@@ -241,7 +326,7 @@ See also documentation at <https://code.visualstudio.com/docs/python/tutorial-dj
241
326
242
327
### Issues during development
243
328
244
-
* If you get a message during login that there is an issue with the CSRF token, e.g. `WARNING:django.security.csrf:Forbidden (CSRF token from POST incorrect.): /loginres/` in the log and also i nthe UI, then switch to using `localhost:8000` as the domain, not the localhost IP used in the examples in this README file.
329
+
- If you get a message during login that there is an issue with the CSRF token, e.g. `WARNING:django.security.csrf:Forbidden (CSRF token from POST incorrect.): /loginres/` in the log and also i nthe UI, then switch to using `localhost:8000` as the domain, not the localhost IP used in the examples in this README file.
0 commit comments