Part of edX code.
edx-django-sites-extensions

This package includes extensions to the Django “sites” framework used by Open edX Django IDAs (independently deployable applications).
Overview
In order to support multitenancy in an IDA, it is helpful to make use of the Django “sites” framework.
One shortcoming of the Django “sites” framework is the fact that the CurrentSiteMiddleware provided by the framework that adds the current site to incoming requests does not allow you to fall back to a site that you can configure in settings in case the current site cannot be determined from the host of the incoming request.
The Django app provided by this package overcomes this issue by monkey patching the django.contrib.sites.models.SiteManager.get_current() function which is called by the CurrentSiteMiddleware to determine the current site. The patched version of this function will first try to determine the current site by checking the host of the incoming request and attempting to match a site by domain. If a site cannot be found this way, it will fall back to the default site configured by setting the SITE_ID setting.
Another issue with the Django “sites” framework is that it uses an in-memory cache of Site models which makes it difficult to update models associated with the Site model via Django admin and have those updates be reflected across all Python processes in a multi-process application environment.
Again the Django app provided by this package monkey patches the private SiteManager query functions that implement the in-memory caching mechanism to add a configurable timeout to the Site cache allowing model updates to be reflected across all processes after the specified timeout.
To enable this functionality in your Django project:
- Install this package in your python environment
$ pip install edx-django-sites-extensions
Add django.contrib.sites.middleware.CurrentSiteMiddleware to your MIDDLEWARE_CLASSES list.
Set the SITE_ID setting:
SITE_ID = 1
This package also provides a mechanism for settings up URL redirects for your application. It makes use of the Django redirects app and provides middleware which will check for Redirect models whose old_path field matches the path of the incoming request and redirects those requests to the new_path of the Redirect model.
To enable this functionality in your Django project:
- Install this package in your python environment
$ pip install edx-django-sites-extensions
Add django_sites_extensions.middleware.RedirectMiddleware to your MIDDLEWARE_CLASSES list.
You can then use Django admin to create Redirect models.
Documentation
The docs for edx-django-sites-extensions are on Read the Docs: https://edx-django-sites-extensions.readthedocs.org.
License
The code in this repository is licensed under LICENSE_TYPE unless otherwise noted.
Please see LICENSE.txt for details.
How To Contribute
Contributions are very welcome.
Please read How To Contribute for details.
Reporting Security Issues
Please do not report security issues in public. Please email security@openedx.org.
Mailing List and IRC Channel
You can discuss this code in the edx-code Google Group.
Metadata
Release files for edx-django-sites-extensions 6.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| edx_django_sites_extensions-6.1.0.tar.gz | 26.6 kB | With provenance | Details for edx_django_sites_extensions-6.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| edx_django_sites_extensions-6.1.0-py3-none-any.whl | Python 3 | none | any | Details for edx_django_sites_extensions-6.1.0-py3-none-any.whl |
Total release size: 45.7 kB
Release files / edx_django_sites_extensions-6.1.0.tar.gz
| Download URL | edx_django_sites_extensions-6.1.0.tar.gz |
|---|---|
| Size | 26.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e1d53a313dae687a8c1906ac24907f60eef72dfb32da9d665cf7af027603a173
|
|
BLAKE2b-256 checksum How to use checksums |
d75bab04b2de0bb60d8f55ba350df033569f44b3ccaa1af67b4e98147fe76cfa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.
Transparency logRelease files / edx_django_sites_extensions-6.1.0-py3-none-any.whl
| Download URL | edx_django_sites_extensions-6.1.0-py3-none-any.whl |
|---|---|
| Size | 19.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
22fa4d930132d2f327419f057ce307ba5ae3f7da52c4d71093e49517437cbea1
|
|
BLAKE2b-256 checksum How to use checksums |
b9604dc8784d9197a9bf0d278d5b5e260c876737ab79ef5c1f98b62671d0d5f9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.
Transparency logSecurity for edx-django-sites-extensions 6.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for edx_django_sites_extensions-6.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.