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)

Project details


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

Uploaded Source

Built Distribution

django_sundial-1.1.1-py2.py3-none-any.whl (6.0 kB view details)

Uploaded Python 2 Python 3

File details

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

File metadata

  • Download URL: django-sundial-1.1.1.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.9

File hashes

Hashes for django-sundial-1.1.1.tar.gz
Algorithm Hash digest
SHA256 18859f56cb4b0b1992854cd1fce8cdb6fb5381949fbda675f27faa46557e44cc
MD5 24c8a91a39a722cfa836803f818d4794
BLAKE2b-256 610e859d56a82dc6c4d33f02b2b8fd0dacfdd7c5b953c9c0bc00b114fffb5c76

See more details on using hashes here.

File details

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

File metadata

  • Download URL: django_sundial-1.1.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.9

File hashes

Hashes for django_sundial-1.1.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 9e624f487a7416b2592c94db052683492059cd7f8455a0fcf62891186bf8e804
MD5 6935e33b7fd3076178099c68c3fefcfa
BLAKE2b-256 620c32a19277179b52593654ace27c8a9e3dd646789a326b6decaf10cb8aaf92

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