Django application providing database, form fields and middleware for timezone support.
Project description
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)
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.0.1.tar.gz
(5.6 kB
view details)
Built Distribution
File details
Details for the file django-sundial-1.0.1.tar.gz
.
File metadata
- Download URL: django-sundial-1.0.1.tar.gz
- Upload date:
- Size: 5.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bf5df51c5a5bbbcbfb1c82a9749e0f5d1bcf8c67985526b76420f81780a513fe |
|
MD5 | 30658f77767ccdb49e7921c446fdb0f1 |
|
BLAKE2b-256 | 5ded9a43d1e144619c56b2f4bbdf284456cb6e9418688d82bd6c8998675f07e1 |
File details
Details for the file django_sundial-1.0.1-py2.py3-none-any.whl
.
File metadata
- Download URL: django_sundial-1.0.1-py2.py3-none-any.whl
- Upload date:
- Size: 9.0 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3a153a49d32c9d240fd89625c2d02e99d1bc37698aa788625b02229e08278ae8 |
|
MD5 | b14fa2387af3de911a89f2273ee5a0c1 |
|
BLAKE2b-256 | d28734f9ba916b67a643f9c8b2c2f0bdca09fd92d2284ad9bfc295b1d939066d |