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.tar.gz
(5.6 kB
view details)
Built Distribution
File details
Details for the file django-sundial-1.0.tar.gz
.
File metadata
- Download URL: django-sundial-1.0.tar.gz
- Upload date:
- Size: 5.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9152e4f6ab3562b76025e44a244da6a4d28a1f57793bd0f32584385d3b1c0413 |
|
MD5 | 9da4bdd5b0c3212c21a3a8150345b3f3 |
|
BLAKE2b-256 | 242a9f226a97b2287b0f40b6f6e6dc0f338f31584586a7356ef947fed742585f |
File details
Details for the file django_sundial-1.0-py2.py3-none-any.whl
.
File metadata
- Download URL: django_sundial-1.0-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 | 6abc012ded8bb037784106b5a4699daed34669ae633d67c0b8fdb6b14f5cdfb7 |
|
MD5 | 0cd3cb45d7d37f3b29431ec042d6d4bb |
|
BLAKE2b-256 | c4249d17a0537edb9e09c954f1d74cba117b5913ddd9a05f6653b8f0499b469d |