0

i'm new here. I'm having a problem with django where i have 'type' which is a reserved keyword as a column in mongodb. Based on answers in stackoverflow, I solved it by applying https://docs.djangoproject.com/en/1.10/ref/models/fields/#django.db.models.Field.db_column

My code currently looked like this

discountType = StringField(required=True, db_column='type')

However, the problem is the field 'type' was changed to 'discountType'. Is there a way to prevent the model from changing the field name?

Naveen Kumar R B
  • 6,248
  • 5
  • 32
  • 65

1 Answers1

0

For mongo db_field is used instead.

See: http://docs.mongoengine.org/guide/defining-documents.html#field-arguments

discountType = StringField(required=True, db_field ='type')
rogeliorv
  • 81
  • 6