Skip to main content

UnixDateTimeField in Django

Project description

[![Build Status](https://travis-ci.org/Niklas9/django-unixdatetimefield.svg?branch=master)](https://travis-ci.org/Niklas9/django-unixdatetimefield) [![Latest Version](https://img.shields.io/pypi/v/django-unixdatetimefield.svg?style=flat) ](https://pypi.python.org/pypi/django-unixdatetimefield/) [![Downloads](https://pepy.tech/badge/django-unixdatetimefield/week)](https://pepy.tech/project/django-unixdatetimefield)

Provides a UnixDateTimeField for your Django models.

I have found this especially useful when integrating Django into legacy databases, where the typical DateTime column type is rather stored as a Unix timestamp (http://en.wikipedia.org/wiki/Unix_time).

UnixDateTimeField is based on the implementation of the standard Django DateTimeField, making it 100% compatible with all features and options it supports.

Usage

First you’ll need to attach a UnixDateTimeField to your model. This acts as a the equivalence of a Django PositiveIntegerField at the database level but provides a Django DateTimeField at the ORM abstraction layer.

Example model:

from django_unixdatetimefield import UnixDateTimeField

class MyModel(models.Model):

created_at = UnixDateTimeField()

Python ORM query:

>>> m = MyModel()
>>> m.created_at = datetime.datetime(2015, 2, 21, 19, 38, 32, 209148)
>>> m.save()

Database:

sqlite> select created_at from mymodel; 1426967129

Enjoy!

Installation

Install with pip (or easy_install):

pip install django-unixdatetimefield

License

BSD, just as the main Django project. See LICENSE file in root of this repo.

Contributing

This project accepts contributions via GitHub pull requests.

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-unixdatetimefield-1.0.3.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

django_unixdatetimefield-1.0.3-py2-none-any.whl (6.7 kB view details)

Uploaded Python 2

File details

Details for the file django-unixdatetimefield-1.0.3.tar.gz.

File metadata

  • Download URL: django-unixdatetimefield-1.0.3.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.5.3

File hashes

Hashes for django-unixdatetimefield-1.0.3.tar.gz
Algorithm Hash digest
SHA256 e1a230ed87dc3d75a2ce0d8841f8fa9d3c8f76503b3bd8f256d7eb0e8ad85585
MD5 b88f37b662dc7f2028ec710f239b3f59
BLAKE2b-256 e1517fb314888c14256ce42f749afaa833b53355aab61d96ccdf50c934d87291

See more details on using hashes here.

File details

Details for the file django_unixdatetimefield-1.0.3-py2-none-any.whl.

File metadata

  • Download URL: django_unixdatetimefield-1.0.3-py2-none-any.whl
  • Upload date:
  • Size: 6.7 kB
  • Tags: Python 2
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.5.3

File hashes

Hashes for django_unixdatetimefield-1.0.3-py2-none-any.whl
Algorithm Hash digest
SHA256 51007d5f30505e2da8fb2d4f6c40c698fdeeadae4f73db72d4de3f41e8f06060
MD5 24953e51033159f90b92cba6ea81c9f9
BLAKE2b-256 6e27eda4abbdf40fbdae49e7460b9162beab755e391600d31d4b89bd9e498361

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