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

incompatible version data for each models.DateField #613

Closed
Admdebian opened this issue Jan 8, 2017 · 4 comments
Closed

incompatible version data for each models.DateField #613

Admdebian opened this issue Jan 8, 2017 · 4 comments

Comments

@Admdebian
Copy link

I have a model: MyModel

I make revisions from scratch and a new sqlite database.
After the first migration I run my test.

My test creates a MyModel instance and saves it two times.

This happens only if I have a DateField in my model. DateTimeField is not affected.
I use JSON serializer.

File "/env/lib/python2.7/site-packages/reversion/models.py", line 206, in _object_version "object_repr": self.object_repr, RevertError: Could not load MyContentString version - incompatible version data.

Can I help?

My virtualenv has:
Django==1.10
django-autofixture==0.12.1
django-modeladmin-reorder==0.2
Pillow>=2.8.1
django-reversion==2.0.8

@etianen
Copy link
Owner

etianen commented Jan 9, 2017 via email

@Admdebian
Copy link
Author

Admdebian commented Jan 9, 2017

At the moment, I put a DateField in the model to test.

This is my commented code:
@cached_property def _object_version(self): data = self.serialized_data data = force_text(data.encode("utf8")) return list(serializers.deserialize(self.format, data, ignorenonexistent=True))[0] try: return list(serializers.deserialize(self.format, data, ignorenonexistent=True))[0] """ except DeserializationError: raise RevertError(ugettext("Could not load %(object_repr)s version - incompatible version data.") % { "object_repr": self.object_repr, }) """ except serializers.SerializerDoesNotExist: raise RevertError(ugettext("Could not load %(object_repr)s version - unknown serializer %(format)s.") % { "object_repr": self.object_repr, "format": self.format, })

This is my new error:
DeserializationError at /admin/MyModule/persone/1/change/
[u"'2017-01-09T02:50:00+01:00' value has an invalid date format. It must be in YYYY-MM-DD format."]: (lzgest.persone:pk=1) field_value was '2017-01-09T02:50:00+01:00'

I have no date format in my settings.py

I suggest we insert a new exception for this case. I think it's very common

@etianen
Copy link
Owner

etianen commented Jan 10, 2017 via email

@Admdebian
Copy link
Author

Admdebian commented Jan 16, 2017

I can't replace the bug anymore.

I don't remember but I guess I've been able to save a datetime in my date attribute because I have skipped the clean() method.

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