Allow args and kwargs to be passed through to_json (#420)
This commit is contained in:
parent
a458d5a176
commit
67f43b2aad
@ -2,6 +2,10 @@
|
||||
Changelog
|
||||
=========
|
||||
|
||||
Changes in 0.8.4
|
||||
================
|
||||
- Allow args and kwargs to be passed through to_json (#420)
|
||||
|
||||
Changes in 0.8.3
|
||||
================
|
||||
- Fixed EmbeddedDocuments with `id` also storing `_id` (#402)
|
||||
|
@ -321,9 +321,9 @@ class BaseDocument(object):
|
||||
message = "ValidationError (%s:%s) " % (self._class_name, pk)
|
||||
raise ValidationError(message, errors=errors)
|
||||
|
||||
def to_json(self):
|
||||
def to_json(self, *args, **kwargs):
|
||||
"""Converts a document to JSON"""
|
||||
return json_util.dumps(self.to_mongo())
|
||||
return json_util.dumps(self.to_mongo(), *args, **kwargs)
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_data):
|
||||
|
@ -827,9 +827,9 @@ class BaseQuerySet(object):
|
||||
|
||||
# JSON Helpers
|
||||
|
||||
def to_json(self):
|
||||
def to_json(self, *args, **kwargs):
|
||||
"""Converts a queryset to JSON"""
|
||||
return json_util.dumps(self.as_pymongo())
|
||||
return json_util.dumps(self.as_pymongo(), *args, **kwargs)
|
||||
|
||||
def from_json(self, json_data):
|
||||
"""Converts json data to unsaved objects"""
|
||||
|
Loading…
x
Reference in New Issue
Block a user