I am trying to query the mongodb
database using the mongoengine
in django
Here's the code:
Document:
class User(Document):
name = StringField(max_length=60, required=True)
meta = {
'collection': 'users'
}
and when I try to query the user with the random string as id, It throws error, but I want None or user object:
User.objects(id='3sdfs')
Here's the error I'm getting
raise ValidationError(message, errors=errors, field_name=field_name)
mongoengine.errors.ValidationError: '3sdfs' is not a valid ObjectId, it must be a 12-byte input or a 24-character hex string