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 = [
...,
'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.6.tar.gz
(5.0 kB
view details)
Built Distribution
File details
Details for the file django-sundial-1.0.6.tar.gz
.
File metadata
- Download URL: django-sundial-1.0.6.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/2.7.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7dd7deff7aea8b2283b8795d5bd19f93d77484518efed6a7605dada7be965665 |
|
MD5 | 8f935e64745c78a3025da67843968f9e |
|
BLAKE2b-256 | d2d72989cf80eec46976ed54a1a6ab89637172f6de534491bf59da27907ac2a4 |
File details
Details for the file django_sundial-1.0.6-py2.py3-none-any.whl
.
File metadata
- Download URL: django_sundial-1.0.6-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.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/2.7.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 08361afffc0da2358d4283e83a0426b862342af211e60d50f273213093306208 |
|
MD5 | e322685697591fac2cb489d4dbd23457 |
|
BLAKE2b-256 | 5c6133db163aa9180ab8951795ca4694fc64a5d58fcc236b8b29eb4a6b125ccb |