Utils for Django's sites framework
Project description
With django-sitesutils you’re able to access current site, using request.site everywhere you can access request object.
Current site is detected using host domain from request object and SITE_ID project setting as a fallback. If site is found, then request.site is set to the respective Site model object from django.contrib.site app, otherwise request.site is a django.contrib.sites.models.RequestSite instance.
Installation
Install django-sitesutils using pip:
$ pip install django-sitesutils
Add RequestSiteMiddleware to your MIDDLEWARE_CLASSES setting:
MIDDLEWARE_CLASSES = ( # ... 'sitesutils.middleware.RequestSiteMiddleware', )
This middleware will set site attribute for the request object. This attribute is evaluated lazily, only when you access it.
If you want to access current site in templates, add site context processor to your TEMPLATE_CONTEXT_PROCESSORS settings:
TEMPLATE_CONTEXT_PROCESSORS = ( # ... 'sitesutils.context_processors.site', )
Contributing
Feel free to fork, send pull requests or report bugs and issues on github.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file django-sitesutils-0.1.2.tar.gz
.
File metadata
- Download URL: django-sitesutils-0.1.2.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 58c14adac7cdd860a324d6535fd4296b2815a4d3defb5f110e8cba4802a5b05c |
|
MD5 | 3f15238b80164c6b7a38305c5f4e36d2 |
|
BLAKE2b-256 | bccbfe4f7323e9046ea0fe8e3ebfc5ab4f30fe2821d31d55a141e7fb832fb7f6 |