django-sage-timezone


Namedjango-sage-timezone JSON
Version 0.1.3 PyPI version JSON
download
home_pageNone
SummaryA project for timezone handling.
upload_time2024-12-19 04:43:56
maintainerNone
docs_urlNone
authorRadin Ghahremani
requires_python<4.0,>=3.10
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
# 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**:

    ```bash
    python -m venv .venv
    ```

2. **Activate the Virtual Environment**:

   - On Windows:

     ```bash
     .venv\Scripts\activate
     ```

   - On macOS/Linux:

     ```bash
     source .venv/bin/activate
     ```

3. **Install `django-sage-timezone`**:

    ```bash
    pip install django-sage-timezone
    ```

### Using `poetry`

1. **Initialize Poetry** (if not already initialized):

    ```bash
    poetry init
    ```

2. **Install `django-sage-timezone`**:

    ```bash
    poetry add django-sage-timezone
    ```

3. **Apply Migrations**:

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

    ```bash
    python manage.py makemigrations
    python manage.py migrate
    ```

## Configuration

### Django Settings

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

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

Also, add the `TimezoneMiddleware` to your middleware settings:

```python
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:

```python
   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.

---

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "django-sage-timezone",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.10",
    "maintainer_email": null,
    "keywords": null,
    "author": "Radin Ghahremani",
    "author_email": "radin@sageteam.org",
    "download_url": "https://files.pythonhosted.org/packages/1d/8f/027996ffa6044e58c38c1b469f58a6ced1372ba16248e207f0dee5e3c56e/django_sage_timezone-0.1.3.tar.gz",
    "platform": null,
    "description": "\n# Django Sage Timezone Management\n\nDjango 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.\n\n## Features\n\n- Adds a \"Select Timezone\" option in the Django Admin navigation bar.\n- Automatically applies the selected timezone to the user's session using middleware.\n- Supports all timezones available through `pytz`.\n- Simple integration with existing Django projects.\n\n## Installation\n\n### Using `pip` with `virtualenv`\n\n1. **Create a Virtual Environment**:\n\n    ```bash\n    python -m venv .venv\n    ```\n\n2. **Activate the Virtual Environment**:\n\n   - On Windows:\n\n     ```bash\n     .venv\\Scripts\\activate\n     ```\n\n   - On macOS/Linux:\n\n     ```bash\n     source .venv/bin/activate\n     ```\n\n3. **Install `django-sage-timezone`**:\n\n    ```bash\n    pip install django-sage-timezone\n    ```\n\n### Using `poetry`\n\n1. **Initialize Poetry** (if not already initialized):\n\n    ```bash\n    poetry init\n    ```\n\n2. **Install `django-sage-timezone`**:\n\n    ```bash\n    poetry add django-sage-timezone\n    ```\n\n3. **Apply Migrations**:\n\n    After installation, ensure to run the following commands to apply necessary migrations:\n\n    ```bash\n    python manage.py makemigrations\n    python manage.py migrate\n    ```\n\n## Configuration\n\n### Django Settings\n\nAdd `django-sage-timezone` to your `INSTALLED_APPS` in the Django settings:\n\n```python\nINSTALLED_APPS = [\n    ...\n    \"sage_timezone\",\n    \"django.contrib.admin\"\n]\n```\n\nAlso, add the `TimezoneMiddleware` to your middleware settings:\n\n```python\nMIDDLEWARE = [\n    \"django.contrib.sessions.middleware.SessionMiddleware\",\n    \"sage_timezone.middleware.TimezoneMiddleware\",\n    ...\n]\n```\n\n### Important Note:\n\nThe `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.\n\n## Note:\nYou can set a custom session name in your Django settings using the `TIME_ZONE_SESSION_NAME` setting. For example:\n\n```python\n   TIME_ZONE_SESSION_NAME = 'your_custom_session_name'\n```\n\n\n## Usage\n\nOnce 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.\n\n---\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "A project for timezone handling.",
    "version": "0.1.3",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c2140a573848395acc38ceddf76b876aeb8c151de722d9ccde521ccbea0427ec",
                "md5": "293837a032f7213866bc8b11fdb6a7e1",
                "sha256": "b8d7d246eb496a673e315617e82300b75decd83b9b63019cc313e73e7682188c"
            },
            "downloads": -1,
            "filename": "django_sage_timezone-0.1.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "293837a032f7213866bc8b11fdb6a7e1",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.10",
            "size": 13729,
            "upload_time": "2024-12-19T04:43:53",
            "upload_time_iso_8601": "2024-12-19T04:43:53.823437Z",
            "url": "https://files.pythonhosted.org/packages/c2/14/0a573848395acc38ceddf76b876aeb8c151de722d9ccde521ccbea0427ec/django_sage_timezone-0.1.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1d8f027996ffa6044e58c38c1b469f58a6ced1372ba16248e207f0dee5e3c56e",
                "md5": "d896e037374c0d2bb6f472479e79d7e0",
                "sha256": "7aa1a3ec706fac3f559b9feeab8d282678d6e424b1ced743734c0c921e08647b"
            },
            "downloads": -1,
            "filename": "django_sage_timezone-0.1.3.tar.gz",
            "has_sig": false,
            "md5_digest": "d896e037374c0d2bb6f472479e79d7e0",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.10",
            "size": 10423,
            "upload_time": "2024-12-19T04:43:56",
            "upload_time_iso_8601": "2024-12-19T04:43:56.395438Z",
            "url": "https://files.pythonhosted.org/packages/1d/8f/027996ffa6044e58c38c1b469f58a6ced1372ba16248e207f0dee5e3c56e/django_sage_timezone-0.1.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-19 04:43:56",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "django-sage-timezone"
}
        
Elapsed time: 0.42582s