Skip to main content

Django application providing database, form fields and middleware for timezone support.

Project description

https://travis-ci.org/charettes/django-sundial.svg?branch=master https://coveralls.io/repos/charettes/django-sundial/badge.svg?branch=master

Django application providing database, form fields and middleware for timezone support.

Installation

pip install django-sundial

Usage

# settings.py
TIME_ZONE = 'America/Chicago'
AUTH_USER_MODEL = 'app.User'
MIDDLEWARE_CLASSES = [
    ...,
    'django.contrib.sessions.middleware.SessionMiddleware',
    ...,
    'sundial.middleware.TimezoneMiddleware',
    ...,
]
# app/models.py
from django.conf import settings
from django.contrib.auth.models import AbstractUser
from django.contrib.auth.signals import user_logged_in
from django.dispatch.dispatcher import receiver

from sundial.fields import TimezoneField
from sundial.utils import set_session_timezone
from sundial.zones import COMMON_GROUPED_CHOICES

class User(AbstractUser):
    timezone = TimezoneField(
        default=settings.TIME_ZONE, choices=COMMON_GROUPED_CHOICES
    )

@receiver(user_logged_in)
def assign_user_timezone(request, user, **kwargs):
    set_session_timezone(request.session, user.timezone)

Download files

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

Source Distribution

django-sundial-1.0.1.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

django_sundial-1.0.1-py2.py3-none-any.whl (9.0 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file django-sundial-1.0.1.tar.gz.

File metadata

File hashes

Hashes for django-sundial-1.0.1.tar.gz
Algorithm Hash digest
SHA256 bf5df51c5a5bbbcbfb1c82a9749e0f5d1bcf8c67985526b76420f81780a513fe
MD5 30658f77767ccdb49e7921c446fdb0f1
BLAKE2b-256 5ded9a43d1e144619c56b2f4bbdf284456cb6e9418688d82bd6c8998675f07e1

See more details on using hashes here.

File details

Details for the file django_sundial-1.0.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for django_sundial-1.0.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 3a153a49d32c9d240fd89625c2d02e99d1bc37698aa788625b02229e08278ae8
MD5 b14fa2387af3de911a89f2273ee5a0c1
BLAKE2b-256 d28734f9ba916b67a643f9c8b2c2f0bdca09fd92d2284ad9bfc295b1d939066d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page