{"id":16216819,"url":"https://github.com/adamcharnock/django-tz-detect","last_synced_at":"2025-05-15T07:07:24.255Z","repository":{"id":9039374,"uuid":"10801810","full_name":"adamcharnock/django-tz-detect","owner":"adamcharnock","description":"Easy user timezone detection for Django","archived":false,"fork":false,"pushed_at":"2024-11-30T08:06:41.000Z","size":123,"stargazers_count":220,"open_issues_count":14,"forks_count":40,"subscribers_count":7,"default_branch":"develop","last_synced_at":"2025-04-25T11:50:55.590Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://pypi.python.org/pypi/django-tz-detect","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/adamcharnock.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGES.txt","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-06-19T17:48:49.000Z","updated_at":"2025-04-11T22:33:50.000Z","dependencies_parsed_at":"2024-10-30T16:01:10.789Z","dependency_job_id":"22ec09a1-81d7-4b6f-be01-2cdf8b22650d","html_url":"https://github.com/adamcharnock/django-tz-detect","commit_stats":{"total_commits":145,"total_committers":18,"mean_commits":8.055555555555555,"dds":"0.46896551724137936","last_synced_commit":"30a7c21664dfae43539d649d8af2ec9ba1a9429b"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adamcharnock%2Fdjango-tz-detect","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adamcharnock%2Fdjango-tz-detect/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adamcharnock%2Fdjango-tz-detect/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adamcharnock%2Fdjango-tz-detect/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adamcharnock","download_url":"https://codeload.github.com/adamcharnock/django-tz-detect/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254292042,"owners_count":22046426,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-10T11:22:41.819Z","updated_at":"2025-05-15T07:07:19.239Z","avatar_url":"https://github.com/adamcharnock.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"django-tz-detect\n================\n\n.. image:: https://img.shields.io/pypi/v/django-tz-detect.svg\n    :target: https://pypi.python.org/pypi/django-tz-detect/\n\n.. image:: https://img.shields.io/pypi/dm/django-tz-detect.svg\n    :target: https://pypi.python.org/pypi/django-tz-detect/\n\n.. image:: https://img.shields.io/github/license/adamcharnock/django-tz-detect.svg\n    :target: https://pypi.python.org/pypi/django-tz-detect/\n\n.. image:: https://coveralls.io/repos/adamcharnock/django-tz-detect/badge.svg?branch=develop\n    :target: https://coveralls.io/r/adamcharnock/django-tz-detect?branch=develop\n\nThis app will auto-detect a user's timezone using JavaScript, then\nconfigure Django's timezone localization system accordingly. As a\nresult, dates shown to users will be in their local timezones.\n\nAuthored by `Adam Charnock \u003chttps://adamcharnock.com/\u003e`_ (who is available for freelance/contract work), and some great `contributors \u003chttps://github.com/adamcharnock/django-tz-detect/contributors\u003e`_.\n\nHow it works\n------------\n\nOn the first page view you should find that ``tz_detect`` places a\npiece of asynchronous JavaScript code into your page using the\ntemplate tag you inserted.  The script will obtain the user's GMT\noffset using ``getTimezoneOffset``, and post it back to Django. The\noffset is stored in the user's session and Django's timezone awareness\nis configured in the middleware.\n\nThe JavaScript will not be displayed in future requests.\n\nInstallation\n------------\n\n1. Either checkout ``tz_detect`` from GitHub, or install using pip:\n\n   .. code-block:: bash\n\n       pip install django-tz-detect\n\n2. Add ``tz_detect`` to your ``INSTALLED_APPS``:\n\n   .. code-block:: python\n\n       INSTALLED_APPS += (\n           'tz_detect',\n       )\n\n3. Be sure you have the ``django.template.context_processors.request`` processor\n   \n   .. code-block:: python\n\n       TEMPLATES = [\n           {\n               ...\n               'OPTIONS': {\n                   'context_processors': [\n                       ...\n                       'django.template.context_processors.request',\n                   ],\n               },\n           },\n       ]\n\n4. Update your ``urls.py`` file:\n\n   .. code-block:: python\n\n       urlpatterns += [\n           path('tz_detect/', include('tz_detect.urls')),\n       ]\n\n5. Add the detection template tag to your site, ideally in your base layout just before the ``\u003c/body\u003e`` tag:\n\n   .. code-block:: html+django\n\n       {% load tz_detect %}\n       {% tz_detect %}\n\n6. Add ``TimezoneMiddleware`` to ``MIDDLEWARE``:\n\n   .. code-block:: python\n\n       import django\n\n       MIDDLEWARE += (\n           'tz_detect.middleware.TimezoneMiddleware',\n       )\n\n       if django.VERSION \u003c (1, 10):\n           MIDDLEWARE_CLASSES += (\n               'tz_detect.middleware.TimezoneMiddleware',\n           )\n\n7. (Optional) Configure optional settings\n\n   Set the countries in which your app will be most commonly used:\n\n   .. code-block:: python\n\n       # These countries will be prioritized in the search\n       # for a matching timezone. Consider putting your\n       # app's most popular countries first.\n       # Defaults to the top Internet using countries.\n       TZ_DETECT_COUNTRIES = ('CN', 'US', 'IN', 'JP', 'BR', 'RU', 'DE', 'FR', 'GB')\n\n   Set the session key that will be used to store the detected timezone\n\n   .. code-block:: python\n\n       # Session key to use, defaults to \"detected_tz\"\n       TZ_SESSION_KEY = \"my-session-key\"\n\nPlease see ``example`` application. This application is used to manually\ntest the functionalities of this package. This also serves as a good\nexample.\n\nYou need only Django 1.8 or above to run that. It might run on older\nversions but that is not tested.\n\nCaveats\n-------\n\n- Django's timezone awareness will not be available on the first page view\n- This method requires JavaScript\n- Timezone detection is done entirely from the user's GMT offset, not from their location\n\nFuture expansion\n----------------\n\n- A hook to allow the timezone to be stored against a user\n- Allow timezones to be manually specified\n- Improve timezone detection\n- Optionally using HTML5's location API for better timezone determination\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadamcharnock%2Fdjango-tz-detect","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadamcharnock%2Fdjango-tz-detect","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadamcharnock%2Fdjango-tz-detect/lists"}