Skip to content

Commit 55cea3b

Browse files
committed
Update error template docs
1 parent ad146bd commit 55cea3b

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

plain/plain/views/README.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -251,19 +251,17 @@ class ExampleView(DetailView):
251251

252252
## Error views
253253

254-
HTTP errors are automatically rendered using templates. Create a template named `<status_code>.html` in your templates directory to customize the error page for that status code.
255-
256-
For example:
254+
HTTP errors are rendered using templates. Create templates for the errors users actually see:
257255

258256
- `templates/404.html` - Page not found
259257
- `templates/403.html` - Forbidden
260258
- `templates/500.html` - Server error
261-
- `templates/4xx.html` - Generic fallback for all 4xx errors
262-
- `templates/5xx.html` - Generic fallback for all 5xx errors
263259

264-
Plain will first look for a specific status code template (e.g., `404.html`), then fall back to the category template (e.g., `4xx.html`). If neither exists, a plain HTTP response is returned.
260+
Plain looks for `{status_code}.html`, then `{category}.html` (e.g., `4xx.html`), then returns a plain HTTP response. Most apps only need the three specific templates above.
261+
262+
Templates receive `status_code` and `exception` in context.
265263

266-
The templates receive a context with `status_code` and `exception` variables.
264+
**Note:** `500.html` should be self-contained - avoid extending base templates or accessing database/session, since server errors can occur during middleware or template rendering. `404.html` and `403.html` can safely extend base templates since they occur during view execution after middleware runs.
267265

268266
## Redirect views
269267

0 commit comments

Comments
 (0)