-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Labels
Description
Hi! Thanks for this module! I was hoping I could use this to do queries based on datetime objects, but that doesn't seem possible. Is this something you've left out on purpose? Would it be very hard to implement (I could help with it, but might need some pointers :))?
I'd expected the following to work:
from django.db import models
from unixtimestampfield.fields import UnixTimeStampField
class MyModel(models.Model):
created = UnixTimeStampField(default=timezone.now)>>> from datetime import datetime
>>> from my_models import MyModel
>>> m = MyModel.objects.create()
>>> m.created
datetime.datetime(2016, 12, 19, 13, 41, 8, 746901, tzinfo=<DstTzInfo 'Europe/Amsterdam' CET+1:00:00 STD>)
>>> MyModel.objects.filter(created__date=datetime.date(2016, 12, 19))
Traceback (most recent call last):
File "<console>", line 1, in <module>
TypeError: descriptor 'date' requires a 'datetime.datetime' object but received a 'int'It seems like this module could benefit from a symmetric API (datetime in, datetime out, while in the background floats are used for storage). Right now I need to worry about implementation details when using this module, like doing queries with floats. I hope you can shed some light on this.
Reactions are currently unavailable