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

how to test for empty mongodb query in pymong
read video file from mongodb with pymongo
Get OperationFailure error with PyMongo 2.7.1
Inserting string as regular string in mongodb
Mongos + Pymongo 2.5 ==>No suitable hosts found
pymongo collection add item using update
How to convert objectid to string
Conditional atomic mongo remove with different results
python script to connect to mongodb master
flask-admin and pymongo search
Running code when mongoengine loads a document
Can't replace mongo document
How do I call a function with pymongo using webpy?
python motor offers fetch_next exception on aggregation
python motor mongo cursor length or peek next
PyMongo check if update succeeded

Categories

HOME
hpoo
oracle
blast
ontouchlistener
softlayer
command-prompt
initialization
typeerror
twitter-fabric
ontology
share
timber
jpa-criteria
xades4j
fireloop
smooks
angular4
sonata
django-rq
synthesis
coroutine
jest
neo4j.rb
uislider
history.js
macromedia
microprocessors
credit-card
markov-chains
buildforge
spinner
system-on-chip
virtual-memory
sendinput
music21
sonicmq
renderman
sonatype
webvtt
sequence-diagram
wikimapia
case-when
mpmovieplayercontroller
maatwebsite-excel
ogg
jenkins-workflow
openseadragon
fiber
noclassdeffounderror
frame-grab
facebook-ios-sdk
currency-exchange-rates
jsr363
diawi
variable-length-array
vdm-sl
tree-structure
mod-auth-openidc
mojo
phonegap-facebook-plugin
juttle
dnsjava
communicate
stripe.net
thruway
ivalueconverter
usb-flash-drive
pbkdf2
dibs
arel
handshake
voice-recording
acpi
n-queens
net-use
database-deadlocks
nosetests
tablet-pc
libxslt
android-2.1-eclair
aggregator
version-control-migration
gui-designer
regioninfo

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App