This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

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

  1. Install django-sitesutils using pip:

    $ pip install django-sitesutils
    
  2. 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.

  3. 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.

Release History

Release History

This version
History Node

0.1.2

History Node

0.1.1

History Node

0.1

Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
django-sitesutils-0.1.2.tar.gz (4.3 kB) Copy SHA256 Checksum SHA256 Source Aug 22, 2012

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting