ktowen / django_partial_date Goto Github PK
View Code? Open in Web Editor NEWDjango custom model field for partial dates with the form YYYY, YYYY-MM, YYYY-MM-DD
License: MIT License
Django custom model field for partial dates with the form YYYY, YYYY-MM, YYYY-MM-DD
License: MIT License
Is it possible to add utcoffset method to the module?
I'm trying to use it with django-import-export module but they are not compatible.
How to reproduce:
Make sure you have enabled the custom module in your Python virtual environment:
pip install django-partial-date==1.3.2 django-reversion==5.0.4
Create the following class in the django models.py:
from partial_date import PartialDateField
class Station(models.Model):
name = models.CharField(max_length=200)
created = PartialDateField(blank=True, null=True)
Register the administration of the object with reversion in admin.py:
from reversion.admin import VersionAdmin
@admin.register(Station)
class StationAdmin(VersionAdmin):
pass
run migrations on your commandline:
python manage.py makemigrations
python manage.py migrate
Hi, it's great library! One question, if only month and day are available, could django_partial_date store only month and day without year? something like:
dob=PartialDate(datetime.date(0, 9, 21), precision=PartialDate.DAY)
Thanks!
I am working on a project that has start and end date fields. Ideally the end date field would be optional.
However PartialDate won't accept an empty string, or None despite what it says in the documentation; or null=True.
These are the kind of errors I have received -
["'' is not a valid date string (YYYY, YYYY-MM, YYYY-MM-DD)"]
When using PartialDate
objects having different precision to define a (partial) date range, the dates are always computed from the 1st of the (month/year) of either PartialDate
object, which is not necessarily correct.
Example:
>>> from partial_date import PartialDate
>>> date_from = PartialDate("2000-05")
>>> date_until = PartialDate("2000")
>>> date_from
2000-05
>>> date_from.precision
1
>>> date_until
2000
>>> date_until.precision
0
>>> date_from < date_until
False
>>> date_from > date_until
True
In this case, either cases should be true because of the lower date accuracy (precision) of date_until
:
date_from < date_until
date_from > date_until
I think we need a PartialDateField in forms because of PartialDateField for models exist.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.