Skip to main content

django-sundial

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)

Metadata

Release files for django-sundial 1.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-sundial 1.1.1
File Size Uploaded
django-sundial-1.1.1.tar.gz 4.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-sundial 1.1.1
File Interpreter ABI Platform
django_sundial-1.1.1-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 10.9 kB

Release files / django-sundial-1.1.1.tar.gz

Download URL django-sundial-1.1.1.tar.gz
Size 4.8 kB
Tags Source
SHA-256 checksum
How to use checksums
18859f56cb4b0b1992854cd1fce8cdb6fb5381949fbda675f27faa46557e44cc
BLAKE2b-256 checksum
How to use checksums
610e859d56a82dc6c4d33f02b2b8fd0dacfdd7c5b953c9c0bc00b114fffb5c76
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / django_sundial-1.1.1-py2.py3-none-any.whl

Download URL django_sundial-1.1.1-py2.py3-none-any.whl
Size 6.0 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
9e624f487a7416b2592c94db052683492059cd7f8455a0fcf62891186bf8e804
BLAKE2b-256 checksum
How to use checksums
620c32a19277179b52593654ace27c8a9e3dd646789a326b6decaf10cb8aaf92
Upload date
Uploaded using Trusted Publishing?
What is 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

Release history Release notifications | RSS feed

This release

1.1.1 This release

2 release files

1.0.6

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page