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.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

django_sundial-1.0-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.tar.gz.

File metadata

File hashes

Hashes for django-sundial-1.0.tar.gz
Algorithm Hash digest
SHA256 9152e4f6ab3562b76025e44a244da6a4d28a1f57793bd0f32584385d3b1c0413
MD5 9da4bdd5b0c3212c21a3a8150345b3f3
BLAKE2b-256 242a9f226a97b2287b0f40b6f6e6dc0f338f31584586a7356ef947fed742585f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for django_sundial-1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 6abc012ded8bb037784106b5a4699daed34669ae633d67c0b8fdb6b14f5cdfb7
MD5 0cd3cb45d7d37f3b29431ec042d6d4bb
BLAKE2b-256 c4249d17a0537edb9e09c954f1d74cba117b5913ddd9a05f6653b8f0499b469d

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