2

Pymodm is being used to define my model for the MongoDB collection in Django. I want to declare a field that can store values of any type (List, String, or Integer).   

from pymodm import MongoModel, fields

class DefinitionEntity(MongoModel):
    version = fields.IntegerField(required=True)
    value = fields.CharField(required=True)

I want the "value" field to accept multiple types. Please tell me how to define that.

Sunderam Dubey
  • 1
  • 11
  • 20
  • 40
Ankit Chouhan
  • 45
  • 1
  • 5

1 Answers1

2

You can use Charfield in your model when it should be more generic. Take into consider that your model has to map the database.

Giggest
  • 61
  • 2