Student course catalog example DJango app.
This started as an assignment for a job I was applying for. My python was rusty and I never touched django. I hit some brick walls and decided I didn't want to cut the corners necessary to deliver this applicaiton without properly "fighting" with Django to get it right.
It's still a work in progress at the moment. I intend on demonstrating proper devop techniques e.g:
You have two options for running this in a development environment. You can use docker-compose to run it in docker containers with with postgres for the database, or you can run it locally with pipenv and use SQLite as the backend server.
The main advantages of running outside of docker are you don't need docker installed, and I haven't figured out how to get step through debugging working from PyCharm or Visual Studio code from inside the container.
pipenv installpipenv shellpython manage.py migratepython manage.py loaddata initial_data.jsonpython manage.py runserver 0.0.0.0:8000This project uses pipenv inside its docker container to manage dependencies insted of manually using virtualenv and pip with requirements.txt.
To run a command inside the pipenv virtualenv locally, you must use the command pipenv run command [args].
To run a command inside the already running running docker container, you must use the command docker-compose exec web command [args].
Therefore, to run a command inside the pipenv, inside the already running running docker container, you must use the command docker-compose exec web pipenv run command [args].
If you want to start a new container (e.g. if you don't have the web server running) to run a command just replace docker-compose exec with docker-compose run. Note that this will cause the db container to start up and remain running.
docker-compose run web pipenv run python manage.py migratedocker-compose up -d or to to keep a tail of the container console messages in a new terminal omit the -d (i.e. docker-compose up)docker-compose exec web pipenv run python manage.py loaddata initial_data.jsondocker-compose exec web pipenv run python manage.py createsuperuser and enter auth informationIf you want to start with a clean databaase the quickest way is with the following commands:
docker-compose rm -fvs dbdocker-compose up -d dbdocker-compose exec web pipenv run python manage.py migratedocker-compose exec web pipenv run python manage.py loaddata initial_data.jsonCreate a docker-compose.override.yml with the following:
version: '3.4'
services:
db:
ports:
- "5432:5432"
#environment:
# POSTGRES_PASSWO: "stud3ntC0urse"
adminer:
image: adminer
ports:
- 8080:8080
Then connect to adminer on http://localuost:8080 or with any other sql client directly.
Unit tests can be run with python manage.py test. They are incomplete and I don't have coverage configured correctly.
I have tested several models in test_models.py and the meta data of one of the views in test_views.py.
Content type
Image
Digest
Size
386.9 MB
Last updated
over 7 years ago
docker pull zippy1981/student-course-management-system