seddonym / django-yearlessdate Goto Github PK
View Code? Open in Web Editor NEWDjango field for storing dates without years
License: BSD 3-Clause "New" or "Revised" License
Django field for storing dates without years
License: BSD 3-Clause "New" or "Revised" License
makemigration with new fields raise an ValueError exception with this traceback:
Traceback (most recent call last):
File "./manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "/code/venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 371, in execute_from_command_line
utility.execute()
File "/code/venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 365, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/code/venv/lib/python3.6/site-packages/django/core/management/base.py", line 288, in run_from_argv
self.execute(*args, **cmd_options)
File "/code/venv/lib/python3.6/site-packages/django/core/management/base.py", line 335, in execute
output = self.handle(*args, **options)
File "/code/venv/lib/python3.6/site-packages/django/core/management/commands/makemigrations.py", line 172, in handle
self.write_migration_files(changes)
File "/code/venv/lib/python3.6/site-packages/django/core/management/commands/makemigrations.py", line 210, in write_migration_files
migration_string = writer.as_string()
File "/code/venv/lib/python3.6/site-packages/django/db/migrations/writer.py", line 151, in as_string
operation_string, operation_imports = OperationWriter(operation).serialize()
File "/code/venv/lib/python3.6/site-packages/django/db/migrations/writer.py", line 110, in serialize
_write(arg_name, arg_value)
File "/code/venv/lib/python3.6/site-packages/django/db/migrations/writer.py", line 74, in _write
arg_string, arg_imports = MigrationWriter.serialize(_arg_value)
File "/code/venv/lib/python3.6/site-packages/django/db/migrations/writer.py", line 279, in serialize
return serializer_factory(value).serialize()
File "/code/venv/lib/python3.6/site-packages/django/db/migrations/serializer.py", line 203, in serialize
return self.serialize_deconstructed(path, args, kwargs)
File "/code/venv/lib/python3.6/site-packages/django/db/migrations/serializer.py", line 90, in serialize_deconstructed
arg_string, arg_imports = serializer_factory(arg).serialize()
File "/code/venv/lib/python3.6/site-packages/django/db/migrations/serializer.py", line 370, in serializer_factory
"topics/migrations/#migration-serializing" % (value, get_docs_version())
ValueError: Cannot serialize: <djangoyearlessdate.helpers.YearlessDate object at 0x7fb228cc4eb8>
There are some values Django cannot serialize into migration files.
For more, see https://docs.djangoproject.com/en/2.0/topics/migrations/#migration-serializing
The has_changed method that gets called on the form does not account for how YearlessDateField is parsed. This causes the field to always be marked as changed whenever an object using this field is saved.
I'll issue a PR shortly to address this.
Having two fields such as :
date_from = models.YearlessDateField()
date_to = models.YearlessDateField()
no_of_days = models.CharField(max_length=50)
i would like to count the number of days btw the date_from and date_to
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.
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.