Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create custom django fields for working with undate and undate interval in a django database #68

Open
3 tasks
rlskoeser opened this issue Nov 16, 2023 · 2 comments
Milestone

Comments

@rlskoeser
Copy link
Member

rlskoeser commented Nov 16, 2023

  • add optional requirements section for django (should not be installed by default); adjust test matrix to test with and without django
  • create and test custom model fields and/or descriptor for undate objects
  • basic validation for supported formats

resources:

@rlskoeser
Copy link
Member Author

rlskoeser commented Nov 16, 2023

S&co approach was to store date as a DateField to take advantage of django and postgres date sorting and filtering, and store a precision object in parallel, that tracked which portions of the date were known. A descriptor was used to combine the date and precision flag into a PartialDate that took the known/unknown portions into account. We have a custom queryset filter for filtering on whether a year is known or not based on that precision flag. We created a model mixin that included start and end date (adds precision flag and partial date descriptors).

Date precision flag was never set directly, but was set based on parsing and validating the supported date formats entered into the system, and then used for serializing back out into the needed format. Preferred access was through the descriptor field that combined the date and the precision; some operations required knowing how this was set up (e.g. queryset to filter on start date but then filter to dates with known years)

@ColeDCrawford
Copy link
Collaborator

Here's the python-edtf approach to an EDTFField: https://github.com/ixc/python-edtf/blob/master/edtf/fields.py

@rlskoeser rlskoeser added this to the 1.0 release milestone Jun 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants