zxy_snow
zxy_snow

Reputation: 61

How to get the id (not pk) from mongoengine models?

my models

class Result(Document) :
    id = IntField()
    turn = IntField()
    url = StringField()

the id is not the primary key.

As you know, mongodb will generate a key named '_id'. So I use 'id' for another means. But in the django, the id or pk are means the primary key.

So, how can I get the field I want from the mongodb through django?

THX~

Upvotes: 1

Views: 1477

Answers (1)

Ross
Ross

Reputation: 18101

Currently id is reserved for the primary key - so can't be reused for a non primary key.

Upvotes: 2

Related Questions