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.2.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 2

File details

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

File metadata

  • Download URL: django-unixdatetimefield-1.0.2.tar.gz
  • Upload date:
  • Size: 4.2 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.2.tar.gz
Algorithm Hash digest
SHA256 aec466b57fb595c78b31a8bb85dc727395003a19864644265bcf88c3a1def869
MD5 e3b5e12c2fb5c1c8026ce1a5df43af8a
BLAKE2b-256 efc1ce364a9097c50d8073484ee13475eb6e191bc3206001f54e9b4d1e5ac9d2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: django_unixdatetimefield-1.0.2-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.2-py2-none-any.whl
Algorithm Hash digest
SHA256 4e567dbd853d0a8718a71d92f8f3c7108b605f3b3994e7f7fe7ea05a3b0c67d7
MD5 75d93dc4c50e49c78c1a625a2f817edc
BLAKE2b-256 5d01b875b3829c91a3d77e6c2b54b35073727c545cca179e12540ef6f7b408db

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