from django.db import models

from mongoengine import *
import datetime

connect(db="djangomongo", host="localhost")

DATA_TYPES = ('int', 'str')


class CustomField(EmbeddedDocument):
    name = StringField(required=True)
    field_type = StringField(required=True, choices=DATA_TYPES)
    field_value = DynamicField()

    def clean(self):
        if ((type(self.field_value) != int and self.field_type != 'int') or
                (type(self.field_value) != str and self.field_type != 'str')):
            raise ValidationError("Field types and their values don't match")


class Form(Document):
    user_name = StringField(required=True)
    location = StringField(required=True)
    data = DictField()
    custom_field = ListField(EmbeddedDocumentField(CustomField))

84c0e97117cf7b5c383783a80b65dfab187ad12f
<mask token>


class CustomField(EmbeddedDocument):
    name = StringField(required=True)
    field_type = StringField(required=True, choices=DATA_TYPES)
    field_value = DynamicField()

    def clean(self):
        if type(self.field_value) != int and self.field_type != 'int' or type(
            self.field_value) != str and self.field_type != 'str':
            raise ValidationError("Field types and their values don't match")


class Form(Document):
    user_name = StringField(required=True)
    location = StringField(required=True)
    data = DictField()
    custom_field = ListField(EmbeddedDocumentField(CustomField))

<mask token>
connect(db='djangomongo', host='localhost')
<mask token>


class CustomField(EmbeddedDocument):
    name = StringField(required=True)
    field_type = StringField(required=True, choices=DATA_TYPES)
    field_value = DynamicField()

    def clean(self):
        if type(self.field_value) != int and self.field_type != 'int' or type(
            self.field_value) != str and self.field_type != 'str':
            raise ValidationError("Field types and their values don't match")


class Form(Document):
    user_name = StringField(required=True)
    location = StringField(required=True)
    data = DictField()
    custom_field = ListField(EmbeddedDocumentField(CustomField))

<mask token>
connect(db='djangomongo', host='localhost')
DATA_TYPES = 'int', 'str'


class CustomField(EmbeddedDocument):
    name = StringField(required=True)
    field_type = StringField(required=True, choices=DATA_TYPES)
    field_value = DynamicField()

    def clean(self):
        if type(self.field_value) != int and self.field_type != 'int' or type(
            self.field_value) != str and self.field_type != 'str':
            raise ValidationError("Field types and their values don't match")


class Form(Document):
    user_name = StringField(required=True)
    location = StringField(required=True)
    data = DictField()
    custom_field = ListField(EmbeddedDocumentField(CustomField))

from django.db import models
from mongoengine import *
import datetime
connect(db='djangomongo', host='localhost')
DATA_TYPES = 'int', 'str'


class CustomField(EmbeddedDocument):
    name = StringField(required=True)
    field_type = StringField(required=True, choices=DATA_TYPES)
    field_value = DynamicField()

    def clean(self):
        if type(self.field_value) != int and self.field_type != 'int' or type(
            self.field_value) != str and self.field_type != 'str':
            raise ValidationError("Field types and their values don't match")


class Form(Document):
    user_name = StringField(required=True)
    location = StringField(required=True)
    data = DictField()
    custom_field = ListField(EmbeddedDocumentField(CustomField))

from django.db import models

from mongoengine import *
import datetime

connect(db="djangomongo", host="localhost")

DATA_TYPES = ('int', 'str')


class CustomField(EmbeddedDocument):
    name = StringField(required=True)
    field_type = StringField(required=True, choices=DATA_TYPES)
    field_value = DynamicField()

    def clean(self):
        if ((type(self.field_value) != int and self.field_type != 'int') or
                (type(self.field_value) != str and self.field_type != 'str')):
            raise ValidationError("Field types and their values don't match")


class Form(Document):
    user_name = StringField(required=True)
    location = StringField(required=True)
    data = DictField()
    custom_field = ListField(EmbeddedDocumentField(CustomField))
