wgordon17 / awesome-django-timezones

Easily set a localized timezone for users
MIT License
9 stars 4 forks source link

============================= Awesome Django Timezones

.. image:: https://badge.fury.io/py/awesome-django-timezones.svg :target: https://badge.fury.io/py/awesome-django-timezones

.. image:: https://travis-ci.org/wgordon17/awesome-django-timezones.svg?branch=master :target: https://travis-ci.org/wgordon17/awesome-django-timezones

.. image:: https://codecov.io/gh/wgordon17/awesome-django-timezones/branch/master/graph/badge.svg :target: https://codecov.io/gh/wgordon17/awesome-django-timezones

Easily set a localized timezone for users

Documentation

The full documentation is at https://awesome-django-timezones.readthedocs.io.

Quickstart

Install Awesome Django Timezones::

pip install awesome-django-timezones

Add it to your INSTALLED_APPS:

.. code-block:: python

INSTALLED_APPS = (
    ...
    'awesome_django_timezones',
    ...
)

Add DjangoTimezonesMiddleware to your MIDDLEWARE_CLASSES:

.. code-block:: python

MIDDLEWARE_CLASSES = (
    ...
    'awesome_django_timezones.middleware.TimezonesMiddleware',
    ...
)

Add js/awesome_django_timezones.js to your base template

.. code-block:: html

<script src="https://github.com/wgordon17/awesome-django-timezones/raw/master/{% static 'awesome_django_timezones/js/awesome_django_timezones.js' %}"></script>

(Optional) If you need Django to be timezone aware on the Admin page, you will have to extend the Admin base.html in your_project/templates/admin/base.html

.. code-block:: python

{% extends 'admin/base.html' %}
{% load static %}

{% block footer %}
  {{ block.super }}

  <script src="https://github.com/wgordon17/awesome-django-timezones/raw/master/{% static 'js/awesome_django_timezones.js' %}"></script>

{% endblock %}

Features

Running Tests

Does the code actually work?

::

source <YOURVIRTUALENV>/bin/activate
(myenv) $ pip install -r requirements_test.txt
(myenv) $ tox

Credits

Tools used in rendering this package:

.. Cookiecutter: https://github.com/audreyr/cookiecutter .. cookiecutter-djangopackage: https://github.com/pydanny/cookiecutter-djangopackage .. _ipapi: https://github.com/ipapi-co/ipapi-python