def get_relation_kwargs(field_name, relation_info):
    model_field, related_model = relation_info
    kwargs = {}
    if related_model and not issubclass(related_model, EmbeddedDocument):
        kwargs['queryset'] = related_model.objects

    if model_field:
        if hasattr(model_field, 'verbose_name') and needs_label(model_field, field_name):
            kwargs['label'] = capfirst(model_field.verbose_name)
        if hasattr(model_field, 'help_text'):
            kwargs['help_text'] = model_field.help_text

        kwargs['required'] = model_field.required

        if model_field.null:
            kwargs['allow_null'] = True
        if getattr(model_field, 'unique', False):
            validator = UniqueValidator(queryset=model_field.model.objects)
            kwargs['validators'] = [validator]

    return kwargs
Creating a default instance of a flat relational field.
dataset/ETHPy150Open umutbozkurt/django-rest-framework-mongoengine/rest_framework_mongoengine/utils.py/get_relation_kwargs