Sunday 15 September 2013

Use a custom ID type in mongodb usyng python -


I am using a memodab as a storage backend for some of my information in a Django 1.5 app.

Each document stored in the Mongodb archive has a _id field that is a decrypt made of several strings. Now when I try to recover this information, I map the document in a model class using the Mongoengine: ago>

I can see: < TypeError

  type 
  document = MyClass.objects print document   

The error / view name / id should be an example (str, unicode, object), no & lt; Type 'dict' & gt;

The worse is that when I use to save the writings

  obj = MyClass ({"tag": "sometag"}) Obj.save ()   

I get the same error, but _id = {"tag": "sometag"} was created in the DB archive. >

What could be any thoughts? It may be that this is the case.

Note: I tried to use Embedded Documentfield but the results are the same (error takes the name of my embedded class instead of 'encrypted')

I found:

I was missing the primary_key argument if I Change it to model:

  Class MyClass (document): id = DictField (primary_key = true)   

It starts working on both operations , Read Write more.

Here is the official doctor:

No comments:

Post a Comment