django-yearlessdate icon indicating copy to clipboard operation
django-yearlessdate copied to clipboard

Implement Lookups

Open ghost opened this issue 4 years ago • 4 comments

Would it be possible to implement lookups for the database, so that .filter(birthday__yearlessdate_gte=(YearlessDate(12, 9))) Note: I use a modified version of your code to have a dayless-date, so it might be possible that my examples/code snippets don't match with the intended usage.

ghost avatar May 12 '21 07:05 ghost

Hi and thanks for the issue request!

Offhand I would have thought this already works, but happy to consider a PR for this!

seddonym avatar May 12 '21 13:05 seddonym

So yesterday I had the idea to just an IntergerField, which has lookups already included. Looking at your code reveals that your fields use CharFields: https://github.com/seddonym/django-yearlessdate/blob/4a0c2803f9a418c20a32d478d2f7fd749f96e7bd/djangoyearlessdate/models.py#L44

In my case I directly inherited from models.IntegerField and format my 'dayless-date' in %Y%m.

ghost avatar May 13 '21 07:05 ghost

Looking at your code reveals that your fields use CharFields.

They do indeed!

Sounds like you sorted out your issue?

seddonym avatar May 13 '21 13:05 seddonym

I did, yes, actually, but lookups will work without any further changes if we use IntergerField as parent class, so this might be the way for this package as well.

ghost avatar May 13 '21 15:05 ghost