IMDB clone, movie rating website built with Django and React.
python --version
will return 2.7.16
python3 --version
: will return 3.8.3which python
& which python3
pip install packagename
pip install django
. But if I run that, it will install django on my system. But we don't want that. Since I can have multiple projects on my system and each project might need different version of django and different set of packages. Thus, We want to create a virtual python environment for our project. So that all the package requirements of our project will be installed in that virtual environment and not effect our global/system environment.
python3 -m venv imdb_venv
: -m stands for make. imdb_venv/bin/activate
or source imdb_venv/bin/activate
. Once activated: terminal prompt will start with (imdb_venv)deactivate
pip install django
- installs django (latest: 3.0.6) and pytz library for timezone supportpip install djangorestframework
. and add rest_framework
to settings.py file.pip install --upgrade pip
.django-admin startproject imdb
or django-admin startproject imdb .
if you want it to be created in current directoryimddb_project
to avoid confusion with inside project folder with same name.cd imdb_project
and python manage.py runserver
no need to mention python3 again. Since venv was created with python3. we can directly use python.python manage.py runserver
python manage.py startapp api
or django-admin startapp api
python manage.py makemigrations
python manage.py migrate
python manage.py showmigrations
python manage.py createsuperuser
admin.site.register()
python manage.py makemigrations
and python manage.py migrate
python manage.py runserver
request.data
request.user
no_of_ratings
is added to the response body at: http://127.0.0.1:8000/api/movies/
avg_rating
in Movie model for avg rating.avg_rating
is added to the response body at: http://127.0.0.1:8000/api/movies/
python manage.py migrate
Authorization: Token tokendata
with POST call.router.register('users','UserViewSet')
Authorization: Token tokendataforkiran4
with GET callAuthorization: Token tokendataforkiran4
npx create-react-app imdb_ui
cd imdb_ui
and npm start
Django:
pip install django-cors-headers
'corsheaders.middleware.CorsMiddleware',
after commonmiddlewarecd imdb_ui
npm i --save @fortawesome/fontawesome-svg-core
npm i --save @fortawesome/free-solid-svg-icons
npm i --save @fortawesome/react-fontawesome
npm i --save @fortawesome/fontawesome-svg-core @fortawesome/free-solid-svg-icons @fortawesome/react-fontawesome
${process.env.REACT_APP_API_URL}
in App.js and MovieDetails.jsnpm i react-router-dom
npm i react-cookie
: will use laterthis.props.cookies.set('imdb-token', res.token)