Skip to main content

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

Project description

License Latest Version Build Status Coverage Status Supported Python Versions Wheel Status

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

Uploaded Source

Built Distribution

django_sundial-1.0.2-py2.py3-none-any.whl (8.2 kB view details)

Uploaded Python 2 Python 3

File details

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

File metadata

File hashes

Hashes for django-sundial-1.0.2.tar.gz
Algorithm Hash digest
SHA256 3362b59cca885f36741c6d7164a185ab6d23d057125dfaba70e3d419555c6b30
MD5 0c9531950ff0e8ab31fc12b9a4ea0503
BLAKE2b-256 290d716b29325f9313bcc6df84ffd8f7f908f5c513025f714fdcc0928d55b357

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for django_sundial-1.0.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 3745891337d726041b37aed95005b9c70377116d232157726e48b46aefef1961
MD5 bbb39dea9465b69c4465c9c1613be7a5
BLAKE2b-256 36927d6a1a499e0d4e2bf3eb3f52b2a392559f36fbafc3170136f42f9301cb46

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