A lightweight, production-ready pattern for binding Microsoft SQL Server data to a Syncfusion React Grid via Django REST Framework (DRF). The sample supports complete CRUD (Create, Read, Update, Delete), server-side filtering, searching, sorting, and paging using DataManager + UrlAdaptor with a DRF ModelViewSet.
- SQL Server ↔ Django:
mssql-django+pyodbcconnection with migrations-driven schema - Syncfusion React Grid: Built-in paging, sorting, filtering, searching, and editing
- Full CRUD: Add, edit, and delete directly from the grid
- Server-side Data Operations: Read/search/filter/sort/page handled in DRF
- Configurable Connection: Manage credentials in
settings.py - CORS-Ready: Enable React dev origin for local development
- Node.js LTS (v20+), npm/yarn
- React 18+ (Vite)
- Python 3.11+
- Django 5.2+, Django REST Framework
- Microsoft SQL Server (or adapt to Postgres/MySQL/SQLite)
git clone <your-repo-url>
cd <your-project>Create and activate a virtual environment, then install dependencies:
python -m venv .venv
# Windows
.venv\\Scripts\\activate
# macOS/Linux
# source .venv/bin/activate
pip install django djangorestframework django-filter django-cors-headers mssql-django pyodbcConfigure DATABASES in server/settings.py:
DATABASES = {
"default": {
"ENGINE": "mssql",
"NAME": "LibraryDB",
"USER": "django_user",
"PASSWORD": "Django@123",
"HOST": "(localdb)\MSSQLLocalDB", # or your SQL host
"OPTIONS": {
"driver": "ODBC Driver 18 for SQL Server",
"trustServerCertificate": "yes", # dev only
},
}
}Run migrations and start the API:
python manage.py makemigrations
python manage.py migrate
python manage.py runserver 8000Open the React app and install packages:
npm installRun the React app:
npm run devNavigate to http://localhost:5173.
ENGINE:"mssql"for SQL Server viamssql-djangoOPTIONS.driver: Ensure ODBC Driver 18 for SQL Server is installedtrustServerCertificate: set to"yes"only for local/dev; configure TLS properly for prod
Allow your React dev origin during development:
CORS_ALLOWED_ORIGINS = [
"http://localhost:5173",
]DataManager (UrlAdaptor) behavior
- Read: sends paging (
skip,take), sorting (sorted), filtering (where), and searching (search) as JSON - CRUD: sends
action: 'insert' | 'update' | 'remove'with the appropriate payload
| File/Folder | Purpose |
|---|---|
server/settings.py |
Django/DRF, DB, and CORS configuration |
server/urls.py |
API routing with DefaultRouter |
library/models.py |
BookLending model |
library/services |
Includes services for handling server side operations |
library/views.py |
ModelViewSet exposing endpoints |
src/App.tsx |
React Grid + DataManager config |
src/index.css |
Syncfusion theme imports |
- Click Add in the grid toolbar
- Fill out fields (title, borrower, dates, etc.)
- Click Save to create the record
- Select a row → Edit
- Modify fields → Update
- Select a row → Delete
- Confirm deletion
- Use the Search box (toolbar) to match across configured columns
- Use column filter icons for equals/contains/date filters
- Click column headers to sort ascending/descending
ODBC/Driver errors
- Install ODBC Driver 18 for SQL Server
- Match Python and ODBC driver architecture (64‑bit recommended)
- Verify
pyodbcis installed and importable
CORS blocked
- Confirm
corsheadersis inINSTALLED_APPSand middleware - Add
http://localhost:5173toCORS_ALLOWED_ORIGINS
Migration issues
- Run
python manage.py makemigrations && python manage.py migrate - Check
DATABASEScredentials and server reachability
Date parsing/format
- Ensure front-end date columns use
type="date" - If needed, configure DRF
DATETIME_INPUT_FORMATS/DATE_INPUT_FORMATS