How to serialize ForeignKey in django rest?

Hello, I'm using the latest djnago rest framework.

There is such a model:
class Subscriptions(models.Model):
 """The subscription. Binding of subscribers to mailing lists"""

 subs_list = models.ForeignKey(SubsList, verbose_name='Subscription list', on_delete=models.CASCADE, related_name='subs_list') # the ID of the subscription list
 subscriber = models.ForeignKey(Subscribers, verbose_name='Subscriber', on_delete=models.CASCADE) # ID of the subscriber
 created_date = models.DateTimeField(verbose_name='Created date', auto_now=True) # date add subscriber to subscription list
 deleted = models.NullBooleanField(verbose_name='Deleted') # True-deleted from the subscription list, False/null-in signature sheet


How can I serialize it? The main question is how to serialize ForeignKey, that would be when the request was given to the associated data, i.e. NOT:
"id": 29,
 "created_date": "2018-03-01T14:28:41.237742 Z",
 "deleted": false,
 "subs_list": 1,
 "subscriber": 1

and so:
"id": 29,
 "subs_list": {
 "id": 1,
 "uuid": "d183bab7-af26-48f8-9ef5-ea48e09a95a9",
 "name": "TEST",
 "description": "TEST",
 "created_date": "2018-03-01T13:15:18.808709 Z",
 "deleted": null,
 "user": 6
},
 "subscriber": {
 "id": 1,
 "bot_id": "1",
 "name_messenger": "11",
 "username": "1",
 "first_name": "1",
 "last_name": "1",
 "created_date": "9999-03-01T16:47:51.440000 Z",
 "subscribed": true,
 "chat_bot": "1",
 "phone": "1",
 "user": 1
},
 "created_date": "2018-03-01T14:28:41.237742 Z",
 "deleted": false


I have a serializer:
from rest_framework import serializers
from subscriptions.models.import subscribers Subscriptions
from subscriptions.serializers.subs_list import SubsListSerializer
from subscriptions.serializers.subscribers import SubscribersSerializer


class SubscriptionsSerializer(serializers.ModelSerializer):
 subs_list = SubsListSerializer(read_only=True)
 subscriber = SubscribersSerializer(read_only=True)

 class Meta:
 model = Subscriptions
 fields = '__all__'


When you get requests all ok, but how to update and add data it is not clear error:
IntegrityError at /subscriptions/subscriptions/
null value in column "subs_list_id" violates not-null constraint
DETAIL: Failing row contains (41, 2018-03-01 16:10:02.383625+00, f, null, null).
June 7th 19 at 14:58
0 answer

Find more questions by tags Django