Django Sites Framework Tutorial: Domain Records and Site Context
Django's sites framework represents a site's domain and display name as application data. Other components can use the current site when constructing links or selecting site-related information. That context is useful, but it is not automatically a complete multi-tenant access-control system or a replacement for host validation.
Here's a popular Django Sites Framework video — watch it, then summarize it with one click. Or paste any other YouTube link below.
— or paste your own YouTube link —
Want to keep the key points from a YouTube video? Paste the link below to turn it into structured notes.
Why Use Django Sites Framework Tutorial: Domain Records and Site Context
- Represent domain and name in Site records
- Understand configured current-site selection
- Use site context for outgoing links
- Associate content with sites deliberately
- Distinguish site selection from authorization
Frequently Asked Questions
Does a Site record configure DNS or a TLS certificate?
It stores application-level domain information rather than provisioning network infrastructure. DNS, certificates, and public routing must still be configured through the environment responsible for serving that domain.
Is SITE_ID equivalent to the current request's host in every setup?
A configured site identifier selects a specific record under that arrangement. Host-based selection has its own behavior, so inspect the actual current-site mechanism rather than assuming those two inputs always match.
Can sites provide complete tenant isolation automatically?
A domain context can help select content, but isolation requires explicit record ownership and authorization rules. Installing the framework alone does not prevent one site's users from requesting another site's objects.
Why can generated emails contain an incorrect domain?
Link construction may use the configured Site record rather than the browser address being inspected. Check current-site data and the relevant email workflow before blaming URL reversing for an unrelated domain setting.
Should site domain data replace ALLOWED_HOSTS?
They serve different purposes: site metadata and accepted request host validation. Configure each deliberately instead of assuming one Site database entry automatically establishes every permitted incoming host.