These are my first steps using mongoengine. For now I don't use any
My MongoDB database is already existing and works in a PHP solution. I am
trying to translate my PHP development to Python. In my Python code, I want
to have one file per collection, all in a "models" directory. My
controllers will be outside of the "models" directory and will use theses
models to perform the different tasks. As I have several collections and as
I would need to create common methods for all of the objects, I have
decided to create a generic MongoDocument class extending DynamicDocument,
the objects classes will then extend MongoDocument. The problem is that I
can't access the collections when using meta collection.
Here are the results when I call test.py :
Traceback (most recent call last):
File "testpdt.py", line 5, in <module>
variable = Variables.objects.get(name="nb_articles_fr")
, line 242, in get
models.variable.DoesNotExist: Variables matching query does not exist.
The problem is that apparently Variables doesn't use the "variables"
collection from my database - even if Variables._get_collection_name()
returns "variables". If Variables extends directly DynamicDocument and if I
remove the meta part of models/variables.py, I can acces to the
I must be missing something :)
Don't forget my idea is to have some generic methods for all my objects.
For example, the "update_modified" method could appear in the MongoDocument
class (don't comment about the timestamp, I'm working on old data which was
using timestamps ;) ).
Thanks for any advice !
You received this message because you are subscribed to the Google Groups "mongodb-user"