Start Django Application
PythonDjango
Apr 28, 2024

Django Basic Commands

Tip

প্রথমে VSCode এর টার্মিনাল ওপেন করুন, তারপর নিচের স্টপগুলো ফলো করুন। Run this command in VScode PowerShell step by step: list [এই কমান্ড দিয়ে আপনি যে ফেল্ডারে আছেন, সেই ফোল্ডারে কি কি আছে দেখতে পারবেন।]

আপনি যদি জ্যাঙ্গোর বেসিক জেনে থাকেন তাহলে লিংকের টেমপ্লেট বা বয়লারপ্লেট টি ইউজ করতে পারেন।

Command for path configure

python -m ensurepip

Install Virtual Environments

python -m venv venv

Activate venv (Mac)

source venv/bin/activate

Activate venv (Windows)

venv\Scripts\activate
Warning

If you encounter PowerShell execution errors

powershell -ExecutionPolicy Bypass

Get-ExecutionPolicy
Set-ExecutionPolicy Bypass

Install Django

pip install Django
python -m django --version

To process images, install Pillow:

pip install Pillow

Install Django Rest Framework

pip install djangorestframework
pip install graphene-django
pip install graphene-django
Tip

সকল প্যাকেজগুলো রিকোয়ারমেন্ট ফাইলে এড করে রাখুন, এতে গিটে প্রজেক্ট শেয়ার করলে প্যাকেজ ম্যানেজ করার হ্যাসেল থাকবে না।

Remember to add all packages to the requirements file to manage them easily:

pip freeze > requirements.txt
pip install -r requirements.txt
pip install -r requirements.txt --upgrade

To view installed packages:

pip list

Create a Django Project

django-admin startproject backend
cd backend

Create an App

python manage.py startapp blog

Migrate Database

python manage.py makemigrations
python manage.py migrate

Create a Superuser for Admin Panel

python manage.py createsuperuser

Run the Project

python manage.py runserver

Extra

*To remove one by one

pip uninstall -r requirements.txt

*If we want to remove all at once then

pip uninstall -r requirements.txt -y
Credit

This article inspired by Sezan Mahmud

← Back