Final-Django-Project

A django project which creates an ORM database about movies, directors and actors. The project also implements a text client which uses custom flag commands, so the database can be updated and queried through just using terminal. It also creates an API with CRUD functionality to all 3 tables and its text client can access data through it. Project is also broadened by adding certain tests. Project also contains logging in and out technique through certain urls, it forbiddens not logged in users to access selected urls. There is also a simple caching technique, to speed up api operations.

Installation

Use the package manager pip to install pipenv, django, django-extensions, requests and djangorestframework

pip install pipenv, django, django-extensions, djangorestframework, requests

If you want to use VSCode terminal with this django project you have to select a correct python interpreter. First get knowledge of a venv directory:

pipenv --venv

Copy the returned path and paste it as a custom python interpreter in VSCode (press SHIFT+CTRL+P for a search bar)

Usage

Create virtual environment in project directory and activate it

python -m venv ./venv-orm
.\venv-orm\Scripts\Activate

Then you can access the database. You can work with three main tables, there are various options like adding, deleting, writing out and querying through the tables, in order to learn which flags to use type:

python manage.py movies --help
python manage.py actors --help
python manage.py directors --help

For example to add an actor to the database you can write

python manage.py actors --add --name 'Christian Bale' --date_of_birth '1974-1-30' --latest_movie 'Thor: Love and Thunder'

If you want to access data through API instead use --mode "api" flag, when writing a statement:

python manage.py movies --mode "api" --write

In order to run implemented tests, you shall use django implemented test method:

python manage.py test core
python manage.py test accounts

Post Scriptum

The code was altered to match PEP 8 standards, using autopep8 module

pip install autopep8
autopep8 --in-place --recursive .\MoviesDB_KO\

Type adnotations are implemented in the code, they were checked using mypy module

pip install mypy
mypy .\MoviesDB_KO\