Pamela Fox
commited on
Commit
·
d67a770
1
Parent(s):
20c47af
Updating README and settings
Browse files- .env +0 -5
- README.md +31 -7
- quizsite/settings.py +3 -2
.env
DELETED
@@ -1,5 +0,0 @@
|
|
1 |
-
FLASK_ENV=development
|
2 |
-
DBNAME=quizsite
|
3 |
-
DBHOST=localhost
|
4 |
-
DBUSER=pamelafox
|
5 |
-
DBPASS=
|
|
|
|
|
|
|
|
|
|
|
|
README.md
CHANGED
@@ -16,26 +16,47 @@ https://django-example-quizsite.azurewebsites.net/quizzes/
|
|
16 |
|
17 |
Install the requirements and Git hooks:
|
18 |
|
19 |
-
|
20 |
-
|
21 |
-
|
|
|
|
|
|
|
|
|
22 |
```
|
23 |
|
24 |
-
Create a
|
25 |
-
and update `.env` with the relevant database details.
|
26 |
|
27 |
-
Run the migrations:
|
28 |
|
29 |
```
|
30 |
python manage.py migrate
|
31 |
```
|
32 |
|
33 |
-
Run the local server:
|
34 |
|
35 |
```
|
36 |
python manage.py runserver
|
37 |
```
|
38 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
Run tests:
|
40 |
|
41 |
```
|
@@ -44,6 +65,9 @@ coverage run --source='.' manage.py test quizzes
|
|
44 |
coverage report
|
45 |
```
|
46 |
|
|
|
|
|
|
|
47 |
## Deployment
|
48 |
|
49 |
This repository is set up for deployment on Azure App Service (w/PostGreSQL flexible server) using the configuration files in the `infra` folder.
|
|
|
16 |
|
17 |
Install the requirements and Git hooks:
|
18 |
|
19 |
+
This project has devcontainer support, so you can open it in Github Codespaces or local VS Code with the Dev Containers extension. If you're unable to open the devcontainer,
|
20 |
+
then it's best to first [create a Python virtual environment](https://docs.python.org/3/tutorial/venv.html#creating-virtual-environments) and activate that.
|
21 |
+
|
22 |
+
1. Install the requirements:
|
23 |
+
|
24 |
+
```shell
|
25 |
+
pip install -r requirements.txt
|
26 |
```
|
27 |
|
28 |
+
2. Create an `.env` file using `.env.sample` as a guide. Set the value of `DBNAME` to the name of an existing database in your local PostgreSQL instance. Set the values of `DBHOST`, `DBUSER`, and `DBPASS` as appropriate for your local PostgreSQL instance. If you're in the devcontainer, copy the values from `.env.sample.devcontainer`.
|
|
|
29 |
|
30 |
+
3. Run the migrations:
|
31 |
|
32 |
```
|
33 |
python manage.py migrate
|
34 |
```
|
35 |
|
36 |
+
4. Run the local server:
|
37 |
|
38 |
```
|
39 |
python manage.py runserver
|
40 |
```
|
41 |
|
42 |
+
5. Navigate to "/quizzes" (since no "/" route is defined) to verify server is working.
|
43 |
+
|
44 |
+
### Admin
|
45 |
+
|
46 |
+
This app comes with the built-in Django admin.
|
47 |
+
|
48 |
+
1. Create a superuser:
|
49 |
+
|
50 |
+
```
|
51 |
+
python manage.py createsuperuser
|
52 |
+
```
|
53 |
+
|
54 |
+
2. Restart the server and navigate to "/admin"
|
55 |
+
|
56 |
+
3. Login with the superuser credentials.
|
57 |
+
|
58 |
+
### Testing
|
59 |
+
|
60 |
Run tests:
|
61 |
|
62 |
```
|
|
|
65 |
coverage report
|
66 |
```
|
67 |
|
68 |
+
The same tests are also run as a Github action.
|
69 |
+
|
70 |
+
|
71 |
## Deployment
|
72 |
|
73 |
This repository is set up for deployment on Azure App Service (w/PostGreSQL flexible server) using the configuration files in the `infra` folder.
|
quizsite/settings.py
CHANGED
@@ -27,8 +27,9 @@ SECRET_KEY = "django-insecure-dfln3fbd4mq*jof)t5($@tlgn98z^a)ar7aw^py7s(j#w^x01q
|
|
27 |
# SECURITY WARNING: don't run with debug turned on in production!
|
28 |
DEBUG = True
|
29 |
|
30 |
-
|
31 |
-
|
|
|
32 |
|
33 |
# Application definition
|
34 |
|
|
|
27 |
# SECURITY WARNING: don't run with debug turned on in production!
|
28 |
DEBUG = True
|
29 |
|
30 |
+
CSRF_TRUSTED_ORIGINS = [
|
31 |
+
f"https://{os.getenv('CODESPACE_NAME')}-8000.{os.getenv('GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN')}"
|
32 |
+
]
|
33 |
|
34 |
# Application definition
|
35 |
|