# Path: rest/model_tools.py
# def get_object_id(instance):
#     ct = get_ct(instance)
#     config = ct.get_config()
#     if config and 'lookup' in config:
#         return getattr(instance, config['lookup'])
#     return instance.pk
# 
# Path: rest/exceptions.py
# class ImproperlyConfigured(ImproperlyConfigured):
#     pass


from rest_framework import serializers
from django.core.exceptions import ImproperlyConfigured
    from django.contrib.gis.db import models as model_fields
    from django.contrib.gis.geos import GEOSGeometry
    from django.db import models as model_fields
from django.utils import timezone
from django.core.exceptions import FieldDoesNotExist
from collections import OrderedDict
from django.conf import settings
from rest_framework.utils import model_meta
from html_json_forms.serializers import JSONFormSerializer
from .model_tools import get_object_id
from .exceptions import ImproperlyConfigured
        import json
        import json
            import pystache
            }
            if field_kwargs.get('many', None):
                label_field_kwargs.update(
                    many=True,
                    read_only=True,
                )
            fields[name + '_label'] = serializers.StringRelatedField(
                **label_field_kwargs
            )

        return fields

    @classmethod
    def for_model(cls, model_class, include_fields=None):
        class Serializer(cls):
            class Meta(getattr(cls, 'Meta', object)):
                model = model_class
                if include_fields:
                    fields = include_fields
        return Serializer

    @classmethod
    def for_depth(cls, serializer_depth):
        class Serializer(cls):
            class Meta(getattr(cls, 'Meta', object)):
                depth = serializer_depth
        return Serializer

    def build_relational_field(self, field_name, relation_info):
        if isinstance(relation_info.related_model, str):

# Path: rest/model_tools.py
# def get_object_id(instance):
#     ct = get_ct(instance)
#     config = ct.get_config()
#     if config and 'lookup' in config:
#         return getattr(instance, config['lookup'])
#     return instance.pk
# 
# Path: rest/exceptions.py
# class ImproperlyConfigured(ImproperlyConfigured):
#     pass


# Path: rest/serializers.py
from rest_framework import serializers
from django.core.exceptions import ImproperlyConfigured
    from django.contrib.gis.db import models as model_fields
    from django.contrib.gis.geos import GEOSGeometry
    from django.db import models as model_fields
from django.utils import timezone
from django.core.exceptions import FieldDoesNotExist
from collections import OrderedDict
from django.conf import settings
from rest_framework.utils import model_meta
from html_json_forms.serializers import JSONFormSerializer
from .model_tools import get_object_id
from .exceptions import ImproperlyConfigured
        import json
        import json
            import pystache

            }
            if field_kwargs.get('many', None):
                label_field_kwargs.update(
                    many=True,
                    read_only=True,
                )
            fields[name + '_label'] = serializers.StringRelatedField(
                **label_field_kwargs
            )

        return fields

    @classmethod
    def for_model(cls, model_class, include_fields=None):
        class Serializer(cls):
            class Meta(getattr(cls, 'Meta', object)):
                model = model_class
                if include_fields:
                    fields = include_fields
        return Serializer

    @classmethod
    def for_depth(cls, serializer_depth):
        class Serializer(cls):
            class Meta(getattr(cls, 'Meta', object)):
                depth = serializer_depth
        return Serializer

    def build_relational_field(self, field_name, relation_info):
        if isinstance(relation_info.related_model, str):

            raise ImproperlyConfigured(