Answers for "how to set a foreign key field value to current user django rest framework"

0

how to set a foreign key field value to current user django rest framework

from <yourapp>.models import NewsModel
from rest_framework import serializers


class NewsModelSerializer(serializers.ModelSerializer):
    author = serializers.HiddenField(default=serializers.CurrentUserDefault())
    class Meta:
        model = NewsModel
Posted by: Guest on June-16-2021

Code answers related to "how to set a foreign key field value to current user django rest framework"

Python Answers by Framework

Browse Popular Code Answers by Language