def create_serializers(device_type_cls):
    """Generate DRF serializers for a DeviceType's models.

    Returns (DeviceSerializer, ReadingSerializer) or (None, None) if DRF is not installed.
    """
    try:
        from rest_framework import serializers
    except ImportError:
        return None, None

    device_model = device_type_cls._device_model
    reading_model = device_type_cls._reading_model
    type_name = device_type_cls.__name__

    # Device serializer — hides sensitive auth fields
    device_meta = type(
        "Meta",
        (),
        {
            "model": device_model,
            "fields": "__all__",
            "read_only_fields": [
                "id",
                "status",
                "battery_level",
                "last_seen",
                "mqtt_username",
                "mqtt_password_hash",
                "api_key",
                "created_at",
                "updated_at",
            ],
        },
    )

    DeviceSerializer = type(
        f"{type_name}DeviceSerializer",
        (serializers.ModelSerializer,),
        {"Meta": device_meta},
    )

    # Reading serializer
    reading_fields = ["id", "device", "timestamp", "received_at"]
    reading_fields.extend(device_type_cls._readings.keys())

    reading_meta = type(
        "Meta",
        (),
        {
            "model": reading_model,
            "fields": reading_fields,
            "read_only_fields": ["id", "received_at"],
        },
    )

    ReadingSerializer = type(
        f"{type_name}ReadingSerializer",
        (serializers.ModelSerializer,),
        {"Meta": reading_meta},
    )

    return DeviceSerializer, ReadingSerializer
