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.1.1.tar.gz
(4.8 kB
view details)
Built Distribution
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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 18859f56cb4b0b1992854cd1fce8cdb6fb5381949fbda675f27faa46557e44cc |
|
MD5 | 24c8a91a39a722cfa836803f818d4794 |
|
BLAKE2b-256 | 610e859d56a82dc6c4d33f02b2b8fd0dacfdd7c5b953c9c0bc00b114fffb5c76 |
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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9e624f487a7416b2592c94db052683492059cd7f8455a0fcf62891186bf8e804 |
|
MD5 | 6935e33b7fd3076178099c68c3fefcfa |
|
BLAKE2b-256 | 620c32a19277179b52593654ace27c8a9e3dd646789a326b6decaf10cb8aaf92 |