Django Agile Sites (django_agilesites)
This provides django the ability of dynamic switching of the settings.SIDE_ID. This allows you to then alter the template paths based on the SITE_ID by referencing settings.SITE_FOLDERS.
The way this works is first by dynamically setting (thread-safe) the settings.SITE_ID based on the request.get_host() (which is based in part on request.META['HTTP_HOST']). Once the SITE_ID is established, then it uses that to dynamically look up any template path folder structure you define.
Example / Setup
Lets assume we want to have all traffic going to //beta.foo.com to use our new templates tree
called 'beta' for a new template app_detail.html. This app will allows you to place the
following templates folder structure in your app to achieve this:
app/
templates/
app/
app_detail.html
app_list.html
beta/
app_detail.html
We need to reference the two sites in question - so in the sites app assume the following. SITE_ID: 1 domain: foo.com SITE_ID: 2 domain: beta.foo.com
Now to enable this to work you need to do the following:
-
Add the
django_agilesitesto the settings.INSTALLED_APPS -
Add the
django_agilesites.loaders.AgileSiteAppDirectoriesFinderto the settings.TEMPLATE_LOADERS. I put it first. -
Add the
django_agilesites.middleware.AgileSitesMiddleware'to the settings.MIDDLEWARE_CLASSES -
Add the following settings to reference the folder beta.
SITE_FOLDERS = { 2: 'beta', }
That's it.
Now when you go to //beta.foo.com/app/detail you will use the template in the beta tree and when you go to the list view on beta it will refer to the parent app_list.html.
Notes:
-
You do NOT need to reference the SITE_ID 1 as there isn't a path change for that.
-
You don't have to put every url. We also support the notion of aliases through the use of settings.SITE_ALIASES dictionary. This will force //beta.bar.com to also use the beta templates.
SITE_ALIASES = { 'beta.bar.com': 2, }
Versions
- 1.0.x Django 1.8
- 1.1.x Django 1.9 < 2
Build Process:
- Update the
__version_info__inside of the application. Commit and push. - Tag the release with the version.
git tag <version> -m "Release"; git push --tags - Build the release
rm -rf dist build *egg-info; python setup.py sdist bdist_wheel - Upload the data
twine upload dist/*
Have fun!
Metadata
Release files for django-agilesites 1.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 |
|---|---|---|---|---|
| django_agilesites-1.1.0.tar.gz | 11.1 kB | Without provenance | Details for django_agilesites-1.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_agilesites-1.1.0-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details for django_agilesites-1.1.0-py2.py3-none-any.whl |
Total release size: 21.1 kB
Release files / django_agilesites-1.1.0.tar.gz
| Download URL | django_agilesites-1.1.0.tar.gz |
|---|---|
| Size | 11.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1ea5c3cc0a5263ad29d0eab2f0c30f7a01bb72bd359831781cb6db20b8f3f2cf
|
|
BLAKE2b-256 checksum How to use checksums |
156528b59f1796b94543a88dcf7b7cc3bb94c0234bdc873267932f85a007d259
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / django_agilesites-1.1.0-py2.py3-none-any.whl
| Download URL | django_agilesites-1.1.0-py2.py3-none-any.whl |
|---|---|
| Size | 10.0 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
9b51fc4d6f9b1db4b077f8a4dee4ea0c7c6c24c82c259fa619edabdb4ff003c2
|
|
BLAKE2b-256 checksum How to use checksums |
f7e17a1326e15fd62bcdceff0ba8cfff1736440723b5ca77cc00d6acc1313633
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for django-agilesites 1.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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A 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.