How to initialize a backend app using Django REST Framework - bounswe/bounswe2024group11 GitHub Wiki
This document serves as a comprehensive guide to setting up a backend application using Django and Django REST Framework. It covers the installation process, project setup, and initial API creation.
The purpose of this backend application is to provide an API service using Django, a high-level Python web framework, and Django REST Framework, a powerful toolkit for building Web APIs.
- Python
- pip
Follow the steps appropriate for your operating system to install Python and pip from here.
Assuming the repo will have backend, web, and mobile parts together, create a directory for the backend
app inside your project's root directory.
mkdir ./backend
Optionally, you may create directories for web and mobile parts here.
mkdir web mobile
Before continuing, change your directory to backend
.
cd ./backend
Create and activate a virtual environment to manage dependencies separately from the system Python.
Note: While initializing our project, we decided to use Python 3.12. So create your virtual environments accordingly. You may want to take a look at Python Documentation.
On bash/zsh shells (i.e., on macOS and the most of the Linux-based distros)
python3 -m venv <venv_name>
On Windows
python -m venv <venv_name>
On bash/zsh shells (i.e., on macOS and the most of the Linux-based distros)
source ./<venv_name>/bin/activate
On Windows (either of them)
<venv_name>\Scripts\Activate.ps1 (Powershell)
<venv_name>\Scripts\activate.bat (cmd)
django-admin startproject <myproject>
python manage.py startapp <myapp>
# update settings.py, Installed_apps, etc.
# Building first API