Skip to content

Support Django serialization framework, and dumpdata/loaddata #20

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

Merged
merged 3 commits into from
Mar 5, 2018

Conversation

mx-moth
Copy link
Collaborator

@mx-moth mx-moth commented Mar 5, 2018

This required adding BaseField.value_to_string() and BaseField.to_python() methods.

django_fake_model does not play nice with the serialization framework, so this had to be dropped in favour of using real models.

Fixes #17

Tim Heap added 2 commits March 5, 2018 16:48
Fake models do not play nice with the django serializer framework.
This required adding BaseField.value_to_string() and
BaseField.to_python() methods.
@mx-moth mx-moth requested a review from danni March 5, 2018 05:50
Copy link
Owner

@danni danni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good with one small thing when we can't parse JSON.

# is called with a string, assume it was produced by value_to_string
# and decode it
if isinstance(value, str):
value = json.loads(value)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to handle the possibility of this choking, since who knows what random thing we got pointed at. If we can't parse it let's let our super have a go.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, but looking at how the rest of Django handles this case, raising a ValidationError on bad data in to_python is the accepted solution. I'll go do that.

@mx-moth mx-moth force-pushed the feature/serialization branch from 0dca15f to 4f368f6 Compare March 5, 2018 22:49
@mx-moth mx-moth merged commit b66d379 into danni:master Mar 5, 2018
@mx-moth mx-moth deleted the feature/serialization branch March 5, 2018 22:53
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

Successfully merging this pull request may close these issues.

2 participants