- Install Docker
cp .env.example .env
- Set the variables in
.env
file accordingly - Go to the root folder of the project and run
docker compose up
. Alternatively, just execute thestartDockerized.bat
file in the root folder (only valid for Windows OS). This will create and start 3 different services, one for postgres, one for django (which will run django's migrate and runserver commands) and one for pgdmin. - Import database if provided (see next section for database connection)
- Extract
posters.zip
and put the poster images instatic/images/posters
- Backoffice:
- url: http://localhost:8000/admin/
- username: admin
- password: 12345
Complete connection values can be found in the docker-compose.yml
file.
- To connect to the web application use
localhost:8000
- pgAdmin can be accessed on
localhost:5051
- In case you wish to use an external GUI to connect to the database, you can use
127.0.0.1
as hostname and5432
as port.
NOTE: values set in docker-compose.yml
should reflect the values in settings.py
file (and viceversa).
Rebuilding and restarting django
(alternatively, you can run rebuildDjangoService.bat
which will run the aforementioned commands):
docker compose stop django
docker compose build --no-cache --pull django
docker compose restart django
Rebuilding and restarting postgres
(alternatively, you can run rebuildPostgresService.bat
which will run the following commands):
docker compose stop postgres
docker compose build --no-cache postgres
docker compose restart postgres
Once the docker containers are running you must follow the steps below in case you do not have the database dump and movie posters:
- Download The Movies Dataset
docker exec django-container python manage.py migrate
docker exec -it django-container python manage.py createsuperuser
- Backoffice:
- url: http://localhost:8000/admin/
- credentials: use the username and password set in the previous step
- create
import
folder in the root directory and place the.csv
files of step 0 in it - update the paths in the
.env
file accordingly docker exec django-container python manage.py import_movies -max_rows=1000
. Omit themax_rows
argument to import all the movies. Pass--flush
option to empty movies app db tables (except user table).- Create The Movie Database API. This api key is needed to show movies' posters. Update the
.env
file accordingly. docker exec django-container python manage.py get_movie_posters
. The posters will be saved instatic/images/posters
directory.docker exec django-container python manage.py set_movies_trailer
docker exec django-container python manage.py migrate --fake your_app zero
will drop all the tables related to your_app from the databasedocker exec django-container python manage.py migrate your_app
apply the migrations to the database
docker exec django-container python manage.py flush_movies
docker exec django-container bash -c "echo yes| python manage.py flush"
-> first pipe yes into command (for confirmation of the command), then flush database