Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ dist
.cache
.vscode
.DS_Store
.angular
.angular
.claude/
22 changes: 15 additions & 7 deletions server-examples/django/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,13 @@ A fully working employee directory that demonstrates Handsontable's `dataProvide
**Prerequisites:** Docker (with Compose plugin), Node.js, npm

```bash
cd server-examples
chmod +x setup.sh
./setup.sh
bash setup.sh
```

Or with Make:

```bash
cd server-examples
make
make setup
```

The script will:
Expand All @@ -36,12 +33,22 @@ The script will:

Open **http://localhost:5173** in your browser.

## Available commands

```bash
make setup # Full first-time setup (build → migrate → seed → start)
make backend # Start only the Docker services
make frontend # Install deps and start Vite
make stop # Stop Docker services
make clean # Remove containers, volumes, and node_modules
```

## Project structure

```
server-examples/
server-examples/django/
├── setup.sh # One-run setup script
├── Makefile # Alternative make-based entry point
├── Makefile # Convenience targets
├── docker-compose.yml # PostgreSQL + Django services
├── backend/
│ ├── Dockerfile
Expand All @@ -59,6 +66,7 @@ server-examples/
└── frontend/
├── package.json
├── vite.config.js # Proxies /api/* → localhost:8000
├── favicon.png
├── index.html
└── src/main.js # Handsontable + dataProvider setup
```
Expand Down
12 changes: 7 additions & 5 deletions server-examples/django/backend/employees/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,12 @@ def get_queryset(self):
@action(detail=False, methods=['post'], url_path='create-rows')
@transaction.atomic
def create_rows(self, request):
serializer = EmployeeSerializer(data=request.data, many=True)
serializer.is_valid(raise_exception=True)
serializer.save()
# Return created rows so dataProvider can update its row map with server-assigned ids.
rows_amount = max(1, int(request.data.get('rowsAmount', 1)))
employees = Employee.objects.bulk_create([
Employee(first_name='', last_name='', department='', role='', salary=0)
for _ in range(rows_amount)
])
serializer = EmployeeSerializer(employees, many=True)
return Response(serializer.data, status=201)

@action(detail=False, methods=['patch'], url_path='update-rows')
Expand All @@ -145,7 +147,7 @@ def update_rows(self, request):
updated = []
for row in request.data:
employee = Employee.objects.get(pk=row['id'])
serializer = EmployeeSerializer(employee, data=row, partial=True)
serializer = EmployeeSerializer(employee, data=row['changes'], partial=True)
serializer.is_valid(raise_exception=True)
serializer.save()
updated.append(serializer.data)
Expand Down
2 changes: 0 additions & 2 deletions server-examples/django/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: '3.9'

services:
db:
image: postgres:15-alpine
Expand Down
Binary file added server-examples/django/frontend/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions server-examples/django/frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="icon" type="image/png" href="/favicon.png">
<title>Handsontable — Server-Side Django Example</title>
<style>
body {
Expand Down
Loading