Comments (1)
👍 Here; It seems that the problem is that follow_reference is not implemented when the result set has several records
This is inconsistent with mongoengine to_json method that works on all results sets;
See this code below
print("one supplier : " + Supplier.objects.first().to_json())
print("all suppliers : " + Supplier.objects.all().to_json())
Returns
one supplier : {"id": "61090c626bb675ca4e3f844c", "name": "Nory Sup", "created": "2021-08-03T09:29:06.535254"}
all suppliers : [{"name": "Nory Sup", "id": "61090c626bb675ca4e3f844c"}, {"name": "new one1", "created": "2021-08-03T09:29:06.535000", "modified": "2021-08-03T09:29:06.593000", "id": "61090c62cf371f3947f64d3b"}]
With follow reference, this works
print("one supplier follow : " + Supplier.objects.first().to_json(follow_reference=True))
one supplier follow : {"id": "61090c626bb675ca4e3f844c", "name": "Nory Sup", "created": "2021-08-03T09:29:06.535254"}
But the results set response called below
print("all suppliers follow : " + Supplier.objects.all().to_json(follow_reference=True))
Fails with the following error
File "/Users/offer-nory/devel/projects/nory/Inventory-Service/src/scripts/playground.py", line 35, in do_stuff
print("all suppliers follow : " + Supplier.objects.all().to_json(follow_reference=True))
File "/Users/offer-nory/.virtualenvs/Inventory-Service/lib/python3.9/site-packages/mongoengine_goodjson/queryset.py", line 98, in to_json
return json.dumps(lst, *args, **kwargs)
File "/opt/homebrew/Cellar/[email protected]/3.9.4/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/__init__.py", line 234, in dumps
return cls(
File "/Users/offer-nory/.virtualenvs/Inventory-Service/lib/python3.9/site-packages/mongoengine_goodjson/encoder.py", line 38, in __init__
super(GoodJSONEncoder, self).__init__(*args, **kwargs)
TypeError: __init__() got an unexpected keyword argument 'follow_reference'
Will be good to get a response on this please !
from mongoengine-goodjson.
Related Issues (20)
- Possibility to add model class properties in to_json()? HOT 2
- Serialization of DictField of ReferenceField HOT 11
- 2.0? HOT 1
- `DynamicField` to_json error HOT 2
- convert pipeline query result to JSON? HOT 4
- Pushing an Id to db.ListField(gj.FollowReferenceField()) adds an entire object HOT 3
- __unset_gj_flag_sub_field has sometimes raises error. HOT 1
- Deprecation Warning When Executing Alongside Pytest HOT 7
- Unexpected Error while saving Document in MongoEngine after using mongoengine-goodjson HOT 1
- Custom QuerySet cancels goodjson
- Dependency Dashboard
- compatibility problems HOT 2
- No ID replace when returning list of objects HOT 4
- BooleanField to python for "False" executes to True in generate_object_hook HOT 6
- Is there a way to specify which format a DatetimeField will be resolved to? HOT 3
- Documentation
- Make ID attribute the first property HOT 1
- Problem with empty list HOT 4
- Poetry HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mongoengine-goodjson.