pymongo


How to append a document to a 2nd level embedded model list document in Django and mongoengine


I'm currently facing some issues trying to add a embedded model object into a list which is also inside a embedded model list.
I'm using Django nonrel and mongoengine with djangotoolbox.
So, this is my mongo collection:
{
"_id" : ObjectId("517fe872e138235e2cae9e8c"),
"campaigns" : [
{
"payout" : 0.7,
"landing_page" : [ ],
"name" : "A prueba de todo",
"rotate_urls" : null,
"_module" : "setup.models",
"_model" : "Campaigns",
"cloaking" : true,
"rotate_urls_status" : false,
"affiliate_url" : "www.google.com/[[subid]][[c1]][[c2]][[c3]][[c4]]"
},
{
"payout" : 0.7,
"landing_page" : [ ],
"name" : "DOS",
"rotate_urls" : null,
"_module" : "setup.models",
"_model" : "Campaigns",
"cloaking" : true,
"rotate_urls_status" : false,
"affiliate_url" : "www.google.com/[[subid]][[c1]][[c2]][[c3]][[c4]]"
}
],
"category_name" : "videos"}
I have tried for 8 days to append a new document inside "landing_page" which is in the collection with category_name equals to "videos" and which contains a campaigns document with name "DOS"
So, I'm trying to append a new document inside
collection -> campaigns -> landin_page
I have tried using queries like this using django ORM:
affnetworkid = prepared django variable with the document id
collection = Categories.objects.get(id=affnetworkid,campaigns__in={name:campaign_name})
But nothing worked!! I need to return the categories result object which needs to have inside, this:
{
"payout" : 0.7,
"landing_page" : [ ],
"name" : "DOS",
"rotate_urls" : null,
"_module" : "setup.models",
"_model" : "Campaigns",
"cloaking" : true,
"rotate_urls_status" : false,
"affiliate_url" : "www.google.com/[[subid]][[c1]][[c2]][[c3]][[c4]]"
}
So that way I can do this:
collection.landing_page.append(LandingPageClass)
collection.save()
But sadly until now, I have not been able to get the expected result... Can anyone give me a hand on this?
Also each time I try to iterate through a query like this:
a = Categories.objects.get(id=affnetworkid)
I receive an error saying that the returned object is not iterable.
Thanks

Related Links

backup collection using pymongo
How to update Saved Document Extra data in GridFS
How do I deal with Error stated below?
pymongo query return in direct query not in pymongo
Displaying nested dictionaries in flask-admin
mongoengine slow serialization of embedded documents with reference fields
Pymongo error : 'Cursor' object has no attribute 'find' , how to filter it?
Spark Streaming: foreachRDD insert into mongoDB using python?
how to find right version of bson from pip for pymongo/mongoengine
How to enable `projection` in pymongo query class `find()`?
Variables don't hold value for very long pymongo ipython
pymongo upgrade to 3.0.3 causes this statement to fail
UUID to NUUID in Python
how to test for empty mongodb query in pymong
read video file from mongodb with pymongo
Get OperationFailure error with PyMongo 2.7.1

Categories

HOME
mod-rewrite
qc
concurrency
foaf
tabs
google-sheets-query
sympy
anchor
azure-graph-api
fireloop
trace32
jpa-2.0
renderscript
spring-shell
spring-ldap
yii2-basic-app
conda
ratio
router
cellular-network
react-bootstrap-table
region
guice
tilemill
instructions
busboy
stackpanel
nanogallery
uivisualeffectview
swfupload
plane
newtons-method
coverage.py
yoast
web-inspector
audio-converter
spongycastle
rightnow-crm
qvtkwidget
.net-micro-framework
solr-query-syntax
emf-compare
front-camera
d3v4
pjax
visual-studio-monaco
openseadragon
right-to-left
uibinder
outlook.com
miniconda
mousehover
css-paged-media
supercomputers
shell-extensions
findersync
mod-auth-openidc
dos2unix
inequality
screwturn
sqlbindparameter
sql-function
cidr
tabletools
application-server
insertonsubmit
django-facebook
coalesce
delphi-xe4
platform-independent
nsfont
infopath-2007
expression-web
asio
cewolf
photo-management
asp.net-mvc-views
digiflow
hungarian-notation
ios-4.2
spring-modules
source-code-protection
fuzzy-comparison
ntruencrypt
synthesizer

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App