Pamela Fox
commited on
Commit
·
b1501e9
1
Parent(s):
b0bdbe7
Update README and launch.json
Browse files- .vscode/launch.json +1 -1
- README.md +13 -17
.vscode/launch.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
| 6 |
"configurations": [
|
| 7 |
{
|
| 8 |
"name": "Python: Django",
|
| 9 |
-
"type": "
|
| 10 |
"request": "launch",
|
| 11 |
"program": "${workspaceFolder}/src/manage.py",
|
| 12 |
"args": [
|
|
|
|
| 6 |
"configurations": [
|
| 7 |
{
|
| 8 |
"name": "Python: Django",
|
| 9 |
+
"type": "debugpy",
|
| 10 |
"request": "launch",
|
| 11 |
"program": "${workspaceFolder}/src/manage.py",
|
| 12 |
"args": [
|
README.md
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
|
|
|
|
|
| 1 |
[](https://github.com/codespaces/new?hide_repo_select=true&ref=main&repo=pamelafox%2Fdjango-quiz-app&machine=standardLinux32gb&devcontainer_path=.devcontainer%2Fdevcontainer.json&location=WestUs2)
|
| 2 |
[](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com%2Fpamelafox%2Fdjango-quiz-app)
|
| 3 |
|
| 4 |
-
|
| 5 |
-
# Quizzes app
|
| 6 |
-
|
| 7 |
An example Django app that serves quizzes and lets people know how they scored. Quizzes and their questions are stored in a PostgreSQL database. There is no user authentication or per-user data stored.
|
| 8 |
|
| 9 |

|
|
@@ -36,18 +35,17 @@ If you're not using one of those options for opening the project, then you'll ne
|
|
| 36 |
|
| 37 |
## Local development
|
| 38 |
|
| 39 |
-
|
| 40 |
1. 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 exactly from `.env.sample`.
|
| 41 |
|
| 42 |
2. Run the migrations: (Also available as a VS Code task)
|
| 43 |
|
| 44 |
-
```
|
| 45 |
python3 src/manage.py migrate
|
| 46 |
```
|
| 47 |
|
| 48 |
3. Run the local server at port 8000: (Also available as a VS Code task)
|
| 49 |
|
| 50 |
-
```
|
| 51 |
python3 src/manage.py runserver 8000
|
| 52 |
```
|
| 53 |
|
|
@@ -59,9 +57,9 @@ This app comes with the built-in Django admin interface.
|
|
| 59 |
|
| 60 |
1. Create a superuser:
|
| 61 |
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
|
| 66 |
2. Restart the server and navigate to "/admin"
|
| 67 |
|
|
@@ -71,7 +69,7 @@ This app comes with the built-in Django admin interface.
|
|
| 71 |
|
| 72 |
Run tests:
|
| 73 |
|
| 74 |
-
```
|
| 75 |
python3 src/manage.py collectstatic
|
| 76 |
coverage run --source='.' src/manage.py test quizzes
|
| 77 |
coverage report
|
|
@@ -79,7 +77,6 @@ coverage report
|
|
| 79 |
|
| 80 |
The same tests are also run as a Github action.
|
| 81 |
|
| 82 |
-
|
| 83 |
## Deployment
|
| 84 |
|
| 85 |
This repository is set up for deployment on Azure App Service (w/PostgreSQL flexible server) using the configuration files in the `infra` folder.
|
|
@@ -102,7 +99,7 @@ This repository is set up for deployment on Azure App Service (w/PostgreSQL flex
|
|
| 102 |
|
| 103 |
5. To be able to access `/admin`, you'll need a Django superuser. Navigate to the Azure Portal for the App Service, select SSH, and run this command:
|
| 104 |
|
| 105 |
-
```
|
| 106 |
python manage.py createsuperuser
|
| 107 |
```
|
| 108 |
|
|
@@ -142,15 +139,14 @@ Pricing varies per region and usage, so it isn't possible to predict exact costs
|
|
| 142 |
|
| 143 |
You can try the [Azure pricing calculator](https://azure.com/e/560b5f259111424daa7eb23c6848d164) for the resources:
|
| 144 |
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
|
| 150 |
⚠️ To avoid unnecessary costs, remember to take down your app if it's no longer in use,
|
| 151 |
either by deleting the resource group in the Portal or running `azd down`.
|
| 152 |
|
| 153 |
-
|
| 154 |
## Getting help
|
| 155 |
|
| 156 |
If you're working with this project and running into issues, please post in **Discussions**.
|
|
|
|
| 1 |
+
# Django + PostgreSQL sample app
|
| 2 |
+
|
| 3 |
[](https://github.com/codespaces/new?hide_repo_select=true&ref=main&repo=pamelafox%2Fdjango-quiz-app&machine=standardLinux32gb&devcontainer_path=.devcontainer%2Fdevcontainer.json&location=WestUs2)
|
| 4 |
[](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com%2Fpamelafox%2Fdjango-quiz-app)
|
| 5 |
|
|
|
|
|
|
|
|
|
|
| 6 |
An example Django app that serves quizzes and lets people know how they scored. Quizzes and their questions are stored in a PostgreSQL database. There is no user authentication or per-user data stored.
|
| 7 |
|
| 8 |

|
|
|
|
| 35 |
|
| 36 |
## Local development
|
| 37 |
|
|
|
|
| 38 |
1. 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 exactly from `.env.sample`.
|
| 39 |
|
| 40 |
2. Run the migrations: (Also available as a VS Code task)
|
| 41 |
|
| 42 |
+
```shell
|
| 43 |
python3 src/manage.py migrate
|
| 44 |
```
|
| 45 |
|
| 46 |
3. Run the local server at port 8000: (Also available as a VS Code task)
|
| 47 |
|
| 48 |
+
```shell
|
| 49 |
python3 src/manage.py runserver 8000
|
| 50 |
```
|
| 51 |
|
|
|
|
| 57 |
|
| 58 |
1. Create a superuser:
|
| 59 |
|
| 60 |
+
```shell
|
| 61 |
+
python3 src/manage.py createsuperuser
|
| 62 |
+
```
|
| 63 |
|
| 64 |
2. Restart the server and navigate to "/admin"
|
| 65 |
|
|
|
|
| 69 |
|
| 70 |
Run tests:
|
| 71 |
|
| 72 |
+
```shell
|
| 73 |
python3 src/manage.py collectstatic
|
| 74 |
coverage run --source='.' src/manage.py test quizzes
|
| 75 |
coverage report
|
|
|
|
| 77 |
|
| 78 |
The same tests are also run as a Github action.
|
| 79 |
|
|
|
|
| 80 |
## Deployment
|
| 81 |
|
| 82 |
This repository is set up for deployment on Azure App Service (w/PostgreSQL flexible server) using the configuration files in the `infra` folder.
|
|
|
|
| 99 |
|
| 100 |
5. To be able to access `/admin`, you'll need a Django superuser. Navigate to the Azure Portal for the App Service, select SSH, and run this command:
|
| 101 |
|
| 102 |
+
```shell
|
| 103 |
python manage.py createsuperuser
|
| 104 |
```
|
| 105 |
|
|
|
|
| 139 |
|
| 140 |
You can try the [Azure pricing calculator](https://azure.com/e/560b5f259111424daa7eb23c6848d164) for the resources:
|
| 141 |
|
| 142 |
+
* Azure App Service: Basic Tier with 1 CPU core, 1.75GB RAM. Pricing is hourly. [Pricing](https://azure.microsoft.com/pricing/details/app-service/linux/)
|
| 143 |
+
* PostgreSQL Flexible Server: Burstable Tier with 1 CPU core, 32GB storage. Pricing is hourly. [Pricing](https://azure.microsoft.com/pricing/details/postgresql/flexible-server/)
|
| 144 |
+
* Key Vault: Standard tier. Costs are per transaction, a few transactions are used on each deploy. [Pricing](https://azure.microsoft.com/pricing/details/key-vault/)
|
| 145 |
+
* Log analytics: Pay-as-you-go tier. Costs based on data ingested. [Pricing](https://azure.microsoft.com/pricing/details/monitor/)
|
| 146 |
|
| 147 |
⚠️ To avoid unnecessary costs, remember to take down your app if it's no longer in use,
|
| 148 |
either by deleting the resource group in the Portal or running `azd down`.
|
| 149 |
|
|
|
|
| 150 |
## Getting help
|
| 151 |
|
| 152 |
If you're working with this project and running into issues, please post in **Discussions**.
|