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

feat: Allow serializer customization for JSONField (#53) #65

Merged

Conversation

kabakchey
Copy link
Contributor

Changes for #53

@skorokithakis
Copy link
Owner

This looks great, thank you! Will review properly within the week.

Copy link
Owner

@skorokithakis skorokithakis left a comment

Choose a reason for hiding this comment

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

I think this looks good, except for a minor concern. Overall, it's much more DRY than before, though.

@@ -65,6 +70,26 @@ class Page(models.Model):
page.save()
"""

def __init__(self, serializer=None, deserializer=None, *args, **kwargs):
Copy link
Owner

Choose a reason for hiding this comment

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

I'm worried that this will break the default order of parameters on the JSONField. Is that the case?

Copy link
Contributor Author

@kabakchey kabakchey Feb 10, 2017

Choose a reason for hiding this comment

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

Yes, that was exactly the case. I've fixed it. Unfortunately, there is no way to keep the signature for an IDE introspection, because we have to support different versions of django.

_PREFIX = 'I can: '

name = models.CharField(max_length="20", default="Igor")
skills = JSONField(default=None, blank=True, null=True,
Copy link
Owner

Choose a reason for hiding this comment

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

This would be a good place to test the default order (by taking out the named arguments and testing before and after the serializer kwargs).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

IMO, there is no need to test args order now.

@kabakchey kabakchey force-pushed the jsonfield_customization branch from 859fef1 to 60d0ef7 Compare February 10, 2017 21:48
@kabakchey
Copy link
Contributor Author

Please, kindly review. Changed init signature to support args order

@skorokithakis skorokithakis merged commit 95614b5 into skorokithakis:master Feb 11, 2017
@skorokithakis
Copy link
Owner

Looks great, thanks!

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