Skip to main content

Date and time dependend content manipulation

Project description

Date and time dependent content manipulation.

Quick start

  1. Install using pip:

    pip install django-time-wizard
  2. Make sure to follow the installation steps for django-polymorphic

  3. Add to your INSTALLED_APPS:

    'polymorphic',
    'time_wizard',
  4. Include the time_wizard admin URLs in your project urls.py:

    path('admin/', include('time_wizard.urls')),
  5. Run python manage.py migrate to create the time_wizard models.

Note

Upgrading from version 0.2.0 to 1.0.0 will delete all the created models of time_wizard!

Usage

You can use the TimeWizard in different ways:

  • use a ForeignKey-relation

    • use one TimeWizardModel-definition for as much models as you want

    • affects your database as the relation needs a new model field

    • example:

      # models.py
      from time_wizard.mixins import TimeWizardMixin
      ...
      class MyModel(TimeWizardMixin, models.Model):
          ...
  • use the PeriodModelInline in the admin

    • each model of yours can have different time-settings

    • does not affect your database as it works with a generic relationship

    • example:

      # models.py
      from time_wizard.mixins import TimeWizardInlineMixin
      ...
      class MyModel(TimeWizardInlineMixin, models.Model):
          ...
      
      # admin.py
      from time_wizard.admin import PeriodModelInline
      from polymorphic.admin import PolymorphicInlineSupportMixin
      ...
      class MyModelAdmin(PolymorphicInlineSupportMixin, admin.ModelAdmin):
          inlines = [PeriodModelInline]
          ...
  • in both ways use is_published on your model to indicate if the content is shown or not.

  • create a custom PeriodModel as a base for custom AbsoluteRange- and HolidayRange-models. There are abstract base classes defined in models/abstract.py. This means you could for example create classes without a generic relation, as PeriodModel itself has.

Settings

Django-time-wizard uses the defined countries and provinces/states from holidays. Definitions need to be compatible with holidays. You can also define this yourself for your needs:

TIME_WIZARD_COUNTRIES = ['US', 'UK', 'DE', ...]
TIME_WIZARD_COUNTRY_PROVINCES = {'US': ['AL', 'AK', ...], ...}

Requirements

  • django

  • django-polymorphic

  • holidays

Tests

Setup your test environment with virtualenv and install the requirements with pip install .. Also install tox via pip and simply run tox.

Tests can also be run via devtools/run-tests. This requires an environment where docker and docker-compose are installed.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_time_wizard-4.2.0.tar.gz (13.2 kB view details)

Uploaded Source

Built Distribution

django_time_wizard-4.2.0-py3-none-any.whl (17.5 kB view details)

Uploaded Python 3

File details

Details for the file django_time_wizard-4.2.0.tar.gz.

File metadata

  • Download URL: django_time_wizard-4.2.0.tar.gz
  • Upload date:
  • Size: 13.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.2

File hashes

Hashes for django_time_wizard-4.2.0.tar.gz
Algorithm Hash digest
SHA256 f7d5462aff62385115ffd7bffe1597cafe9ccfabe093f78b5ef8ba5548bdce44
MD5 d5737ad19b2b1fa66602147f1896eef9
BLAKE2b-256 f0eafa15e3c2d7c5a5e305f87f81753861d9b565293509574f25c8d8aca0cdc1

See more details on using hashes here.

File details

Details for the file django_time_wizard-4.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_time_wizard-4.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 785e343262d0a0f8df3c2da4600e19d191d79d808713f1aaa474ab27533a3f85
MD5 56793bf24f868a58f5a52334f597b06d
BLAKE2b-256 f83d81a8459bbc9b384a0aaaec1423216c7bdcbac8ca828dd5b8bc5d29de2389

See more details on using hashes here.

Supported by

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