Skip to main content

A project for timezone handling.

Project description

Django Sage Timezone Management

Django Sage Timezone Management is a Django package that allows administrators to easily select and apply a timezone for their session directly from the Django Admin interface. Once set, the timezone is automatically applied to all datetime displays during the session.

Features

  • Adds a "Select Timezone" option in the Django Admin navigation bar.
  • Automatically applies the selected timezone to the user's session using middleware.
  • Supports all timezones available through pytz.
  • Simple integration with existing Django projects.

Installation

Using pip with virtualenv

  1. Create a Virtual Environment:

    python -m venv .venv
    
  2. Activate the Virtual Environment:

    • On Windows:

      .venv\Scripts\activate
      
    • On macOS/Linux:

      source .venv/bin/activate
      
  3. Install django-sage-timezone:

    pip install django-sage-timezone
    

Using poetry

  1. Initialize Poetry (if not already initialized):

    poetry init
    
  2. Install django-sage-timezone:

    poetry add django-sage-timezone
    
  3. Apply Migrations:

    After installation, ensure to run the following commands to apply necessary migrations:

    python manage.py makemigrations
    python manage.py migrate
    

Configuration

Django Settings

Add django-sage-timezone to your INSTALLED_APPS in the Django settings:

INSTALLED_APPS = [
    ...
    "sage_timezone",
    "django.contrib.admin"
]

Also, add the TimezoneMiddleware to your middleware settings:

MIDDLEWARE = [
    "django.contrib.sessions.middleware.SessionMiddleware",
    "sage_timezone.middleware.TimezoneMiddleware",
    ...
]

Important Note:

The sage_timezone.middleware.timezone.TimezoneMiddleware must be placed after the django.contrib.sessions.middleware.SessionMiddleware in your MIDDLEWARE setting. This order is crucial to ensure that the session data is available when the timezone is set.

Note:

You can set a custom session name in your Django settings using the TIME_ZONE_SESSION_NAME setting. For example:

   TIME_ZONE_SESSION_NAME = 'your_custom_session_name'

Usage

Once configured, the Django Admin will include a "Select Timezone" option in the navigation bar. Administrators can choose their preferred timezone, which will be applied to their session.


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_sage_timezone-0.1.1.tar.gz (7.4 kB view details)

Uploaded Source

Built Distribution

django_sage_timezone-0.1.1-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

Details for the file django_sage_timezone-0.1.1.tar.gz.

File metadata

  • Download URL: django_sage_timezone-0.1.1.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.4 Windows/11

File hashes

Hashes for django_sage_timezone-0.1.1.tar.gz
Algorithm Hash digest
SHA256 08b709e552270d3f75be21a6c5bb4a98a92a9cd311b70ae179554fb7e43f8634
MD5 2d5bd228c9f6dfff22e001abde2a86ac
BLAKE2b-256 d2f3a6b09a65822dd0c37caa3468473847d2a4022be79306203000927363a5d3

See more details on using hashes here.

File details

Details for the file django_sage_timezone-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for django_sage_timezone-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3ce3d2866ae900bcb606c90908c1add6fa9aaad3343959fd6f295c694018057b
MD5 1abbc9f23fa8a4a754da0c653f5933f7
BLAKE2b-256 7734e8a53aa6e17bdf5cb88d5173d08cc808ad7f02d8378e3c0e303a7546346d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page