How-To GuidesΒΆ
How-to guides answer task-shaped questions. Each recipe states a problem, gives one minimal solution, walks through the steps, and shows how to verify the result. Topic guides cover the underlying concepts, see Topic Guides.
Pages and routing
- Add a Page
Add a new page to a running project.
- Reverse URLs
Build URLs from page templates and Python.
- Reload Routes From Code
Trigger router reload at runtime.
- Write a Router Backend
Implement a router backend that reads URLs from a database.
- Read Query Parameters
Read query-string values with the
DQuerymarker.- Add a Custom Template Loader
Plug an extra
TemplateLoaderintoTEMPLATE_LOADERS.- Require Login on File-Routed Pages
Gate routed pages behind authentication.
- Internationalize Routes
Serve the page tree under per-language URL prefixes.
- Customize 404 and 500 Pages
Replace the default 404 and 500 pages.
Context and components
- Share Context Across Pages
Publish values once for an entire page tree.
- Resolve Feature Flags With DI
Resolve feature flags through a custom dependency provider.
- Build a Composite Component
Build a component that takes content through slots.
- Share Components Across Projects
Reuse a UI kit across several page roots.
Static assets
- Add a New Asset Kind
Recognise a new file extension during static collection.
- Add a Custom Stem
Treat additional filenames as component assets.
- Customise Rendered Static Tags
Customise the rendered link and script tags.
- Override the JS Context Serializer
Replace the default JSON serializer for the
Nextobject.- Resolve Asset URLs Through a Custom Backend
Add a custom asset kind with its own renderer.
Forms
- Handle File Uploads
Accept file inputs in a form action.
- Use ModelForm for CRUD
Power create, update, and delete pages with
ModelForm.- Use Formsets
Render and validate a Django formset.
- Write a Form Action Backend
Plug a new validation pipeline into the dispatcher.
- Extend a Default Backend Entry
Patch one key of a default backend entry through
extend_default_backend.
Testing
- Test a Page With Actions
Test a page that posts to a registered action.
- Test a Component in Isolation
Render and assert on one component without a page.
Integration and operations
- Integrate Django Admin
Run Django admin alongside next.dj pages.
- Scope Requests Per Tenant
Scope every request to one tenant across the stack.
- Observe Framework Signals
Receive framework signals in production receivers.
- Stream Live Updates With SSE
Push live updates to the browser with server-sent events.
- Split Settings per Environment
Split settings into base, dev, and prod modules.