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 = [
    ...,
    '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.4.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

django_sundial-1.0.4-py2.py3-none-any.whl (6.3 kB view details)

Uploaded Python 2 Python 3

File details

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

File metadata

  • Download URL: django-sundial-1.0.4.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.5.2

File hashes

Hashes for django-sundial-1.0.4.tar.gz
Algorithm Hash digest
SHA256 b9580a6c2124d170432fa0de2daae3b09b15d88f04d1aead48941a263618d9c6
MD5 91ccadbd169820b03f6630189fad5e9d
BLAKE2b-256 c19949748b3ca0a45437f0416af9c5d7e5a91eef0bc2e0c74b26d9ebebbd9514

See more details on using hashes here.

File details

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

File metadata

  • Download URL: django_sundial-1.0.4-py2.py3-none-any.whl
  • Upload date:
  • Size: 6.3 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.5.2

File hashes

Hashes for django_sundial-1.0.4-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 c99aab8276e6a0ecd204d46861051f69224ba2f8f1b1e83ac7da9a9ab4023930
MD5 04406a121d18ea573b46314c4a222197
BLAKE2b-256 f85e36f02a46e3c713be9a3500bbf448856e5df14481b9e6512af27e51e262c8

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