Skip to content

Reversion cannot recover PartialDateField versions with an empty value #10

@lefterav

Description

@lefterav

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
  1. Login in the admin interface and create a Station object. Provide only a value for the "name" field and leave all the rest empty. Click save and continue editing.
  2. Provide a partial date value in the "Created" the field. E.g. "2020-05". Click save and continue editing
  3. Click on history.
  4. Click on the older version you created before: unintended behavior: "Could not load Name version - incompatible version data."
  5. Click on the latest version with the partial date specified: intended behavior. The version loads properly

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions