Skip to main content
https://secure.travis-ci.org/trilan/django-sitesutils.png?branch=develop

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 files for django-sitesutils 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-sitesutils 0.1.2
File Size Uploaded
django-sitesutils-0.1.2.tar.gz 4.3 kB Details

Release files / django-sitesutils-0.1.2.tar.gz

Download URL django-sitesutils-0.1.2.tar.gz
Size 4.3 kB
Tags Source
SHA-256 checksum
How to use checksums
58c14adac7cdd860a324d6535fd4296b2815a4d3defb5f110e8cba4802a5b05c
BLAKE2b-256 checksum
How to use checksums
bccbfe4f7323e9046ea0fe8e3ebfc5ab4f30fe2821d31d55a141e7fb832fb7f6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.1.2 This release

1 release file

0.1.1

1 release file

0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page