Python Backend Setup Guide (Beginner Friendly)
This guide uses Python + Django + Django REST Framework (DRF) because Django is one of the most
popular backend frameworks and works very well with Flutter.
1. What is Python?
Python is a programming language used for:
Web Development
APIs
Automation
Data Science
AI / Machine Learning
Desktop Apps
Popular Python frameworks:
Django
FastAPI
Flask
For beginners:
Django → Best choice
FastAPI → Modern and very fast
Flask → Lightweight
2. Install Python
Download:
[Link]
Verify installation:
1
python --version
or
python3 --version
Example:
Python 3.13.x
3. Create Project Folder
mkdir backend
cd backend
4. Create Virtual Environment
Why?
Keeps project packages separate.
Create:
python -m venv venv
Activate:
Windows:
venv\Scripts\activate
Mac/Linux:
2
source venv/bin/activate
You should see:
(venv)
5. Install Django
pip install django
Verify:
django-admin --version
6. Create Django Project
django-admin startproject config .
Project structure:
backend/
config/
[Link]
venv/
7. Run Server
python [Link] runserver
Visit:
3
[Link]
8. Install Django REST Framework
Flutter communicates through APIs.
Install:
pip install djangorestframework
Add to:
INSTALLED_APPS = [
'rest_framework',
File:
config/[Link]
9. Create App
Think of apps like modules.
Create:
python [Link] startapp products
Structure:
products/
[Link]
4
[Link]
[Link]
[Link]
[Link]
Register:
INSTALLED_APPS = [
'rest_framework',
'products',
10. Project Structure
backend/
config/
apps/
│
├── accounts/
├── products/
├── cart/
├── orders/
├── payments/
│
media/
static/
[Link]
Professional structure:
apps/
accounts
products
cart
5
orders
payments
11. Configure Database
Default:
SQLite
Production:
MySQL
PostgreSQL
Example MySQL:
Install:
pip install mysqlclient
[Link]
DATABASES = {
'default': {
'ENGINE': '[Link]',
'NAME': 'ecommerce',
'USER': 'root',
'PASSWORD': '',
'HOST': '[Link]',
'PORT': '3306',
}
6
12. Create Model
products/[Link]
from [Link] import models
class Product([Link]):
name = [Link](max_length=255)
description = [Link](
blank=True,
null=True
)
price = [Link](
max_digits=10,
decimal_places=2
)
stock = [Link]()
image = [Link](
upload_to='products/',
blank=True,
null=True
)
created_at = [Link](
auto_now_add=True
)
13. Create Migration
Generate:
python [Link] makemigrations
Apply:
7
python [Link] migrate
14. Create Serializer
Serializer converts:
Database Object
↓
JSON
Create:
products/[Link]
from rest_framework import serializers
from .models import Product
class ProductSerializer(
[Link]
):
class Meta:
model = Product
fields = '__all__'
15. Create API View
products/[Link]
from rest_framework.response import Response
from rest_framework.views import APIView
from .models import Product
from .serializers import ProductSerializer
8
class ProductListView(APIView):
def get(self, request):
products = [Link]()
serializer =
ProductSerializer(
products,
many=True
)
return Response(
[Link]
)
16. Create Routes
products/[Link]
from [Link] import path
from .views import ProductListView
urlpatterns = [
path(
'',
ProductListView.as_view()
),
Project urls:
config/[Link]
from [Link] import include
from [Link] import path
urlpatterns = [
9
path(
'api/products/',
include('[Link]')
),
Visit:
[Link]
17. MVC Equivalent
Django uses:
Request
↓
URL
↓
View
↓
Model
↓
Database
↓
Serializer
↓
JSON Response
18. Authentication
Install:
pip install djangorestframework-simplejwt
[Link]
10
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework_simplejwt.[Link]',
),
19. Generate JWT Token
POST /api/token/
Response:
{
"access": "token",
"refresh": "token"
}
Flutter stores:
access token
and sends it in headers.
20. Admin Panel
Create admin user:
python [Link] createsuperuser
Run:
11
python [Link] runserver
Open:
[Link]
Login with admin account.
21. Upload Images
Install:
pip install pillow
[Link]
MEDIA_URL = '/media/'
MEDIA_ROOT =
BASE_DIR / 'media'
[Link]
from [Link] import settings
from [Link] import static
urlpatterns += static(
settings.MEDIA_URL,
document_root=settings.MEDIA_ROOT
)
22. Common E-Commerce Tables
users
categories
12
products
product_images
carts
cart_items
orders
order_items
payments
reviews
addresses
23. Flutter Connection
Base URL:
const baseUrl =
"[Link]
Get Products:
final response =
await [Link](
[Link](
'$baseUrl/products/'
)
);
24. Daily Commands
Create app:
13
python [Link] startapp app_name
Run server:
python [Link] runserver
Create migration:
python [Link] makemigrations
Apply migration:
python [Link] migrate
Create admin:
python [Link] createsuperuser
Shell:
python [Link] shell
25. Professional Django Structure
backend/
apps/
│
├── accounts/
├── products/
├── cart/
├── orders/
├── payments/
├── reviews/
│
config/
14
media/
static/
[Link]
Keep:
Models
for database structure,
Views
for business logic,
Serializers
for JSON conversion,
URLs
for routes.
26. Learning Order
1. Python Basics
2. OOP (Classes & Objects)
3. Django Basics
4. Models
5. Migrations
6. Django REST Framework
7. Authentication (JWT)
8. File Uploads
9. Flutter Integration
10. Deployment
15
27. Complete Backend Flow
Flutter App
↓
API Request
↓
URL Route
↓
View
↓
Model
↓
Database
↓
Serializer
↓
JSON Response
↓
Flutter UI
Django is often considered one of the easiest and most productive backend frameworks for beginners
because it includes authentication, admin panel, ORM, migrations, validation, and security features out of
the box.
16