Define field in Django which can be of any type

Question:

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.

Asked By: Ankit Chouhan

||

Answers:

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

Answered By: Giggest
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.