---
url: "https://vueda.dev/v3/reference/api/py/vueda.core.serializers.fields/CompositePrimaryKeyField.md"
title: "CompositePrimaryKeyField"
---

# CompositePrimaryKeyField

## Overview

CompositePrimaryKey returns the pk as a json list:
'["1", "1"]'

Internally it needs to convert it back to a list or tuple queries won't work:
    TupleExact
    TupleGreaterThan
    TupleGreaterThanOrEqual
    TupleLessThan
    TupleLessThanOrEqual
    TupleIn
    TupleIsNull

## `to_internal_value` {#to_internal_value}

Transform the *incoming* primitive data into a native value.

### Signature {#to_internal_value-signature}

`to_internal_value(self, data)`

#### Parameters {#to_internal_value-parameters}

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| self |  | yes |  |  |
| <span id="to_internal_value-param-data">data</span> |  | yes |  |  |

### Source {#to_internal_value-source}

`server/vueda/core/serializers/fields.py:126`

## `to_representation` {#to_representation}

Transform the *outgoing* native value into primitive data.

### Signature {#to_representation-signature}

`to_representation(self, value)`

#### Parameters {#to_representation-parameters}

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| self |  | yes |  |  |
| <span id="to_representation-param-value">value</span> |  | yes |  |  |

### Source {#to_representation-source}

`server/vueda/core/serializers/fields.py:111`

## Source

`server/vueda/core/serializers/fields.py:96`
