--- jd-id: "01.11" name: "django-backend" desc: "External dependency — the Django REST Framework backend that this frontend talks to over HTTP. The base URL is hardcoded in `src/api/index.js`." author: "Clark Lin" updateTime: "2026-07-06" status: active type: "A-高层系统" tags: - Backend - Django - DRF - JWT --- - [[01.00 student-app-frontend]] (← parent project) - [[01.01 src-api]] (← consumer module) The frontend issues JSON requests to a Django REST Framework service running at `http://192.168.1.52:8001`. Authentication uses JWT — the access + refresh pair is obtained from `/api/token/` and `/api/token/refresh/`. ## Endpoint Map (from `src/api/index.js`) | Endpoint | Methods | Used by | |----------|---------|---------| | `/api/token/` | `POST` | `authService.login` | | `/api/token/refresh/` | `POST` | `authService.refreshAccessToken`, `stores/auth.js` | | `/api/students/` | `GET`, `POST` | `studentService` | | `/api/students/{studentId}/` | `PUT`, `DELETE` | `studentService` | | `/api/subjects/` | `GET`, `POST` | `subjectService` | | `/api/subjects/{subjectId}/` | `PUT`, `DELETE` | `subjectService` | | `/api/terms/` | `GET`, `POST` | `termService` | | `/api/terms/{termId}/` | `PUT`, `DELETE` | `termService` | | `/api/stories/` | `GET`, `POST` | `storyService` | | `/api/stories/{storyId}/` | `PUT`, `DELETE` | `storyService` | | `/api/tasks/` and task sub-routes | various | `taskService` (paths hardcoded — not in `apiEndpoints`) | ## Notable Behaviors - DRF returns paginated lists as `{ count, next, previous, results }` — see `fetchAllPages()` in `studentService.js` and `taskService.js`. - Task **images** are returned as binary. The frontend fetches them with `responseType: 'blob'` and `Accept: */*` (`getTaskImage`) — without that header the backend responds `406 Not Acceptable`. ## External Files in This Repo (Not Part of Vue Build) The following live at the repo root but are not part of the Vue app: - `swagger_schema.json` — the OpenAPI/Swagger schema for the backend; consult it before adding/changing API calls. ## Operational Notes - The base URL is **hardcoded** — change `API_BASE_URL` in `src/api/index.js` when the backend moves (no env-based config exists). - The `apiEndpoints` table in `src/api/index.js` is partially stale: `TERMS.UPDATE`/`DELETE` are still template strings (`/api/terms/{termId}/`) instead of functions, and `task`/`story` endpoints aren't listed. Prefer hardcoding paths in the service modules over trusting `apiEndpoints` until it's cleaned up. --- Home: [[01.00 student-app-frontend]] | **Location:** `C:\Projects\vue\student-app-frontend\swagger_schema.json` (spec lives at the project root)