---
title: "Discussion on \"게시글 등록시 pk값이 아닌 username으로 값을 넣고 싶다!\" | Hashnode"
description: "Discussion on \"게시글 등록시 pk값이 아닌 username으로 값을 넣고 싶다!\". 게시글 등록을 할 때 user를 pk가 아닌 username으로 오게 하고 싶어서 serializer의 method field를 사용해보기로 했다. \n\nSerializerMethodField\n읽기 전용 필드로 연결된 serilaizer 클래스에서 메서드를 호출하여 값을 가져온다.SerializerMethodField(method_name=None) \n\nserializer.py\nfrom rest_framework import serializers..."
url: "https://hashnode.com/posts/pk-username/66330ee468320de25f5f32d0"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [게시글 등록시 pk값이 아닌 username으로 값을 넣고 싶다!](https://yeonnan.hashnode.dev/pk-username?utm_source=hashnode&utm_medium=feed)

게시글 등록을 할 때 user를 pk가 아닌 username으로 오게 하고 싶어서 serializer의 method field를 사용해보기로 했다. SerializerMethodField 읽기 전용 필드로 연결된 serilaizer 클래스에서 메서드를 호출하여 값을 가져온다.SerializerMethodField(method\_name=None) serializer.py from rest\_framework import serializers...

May 2, 2024 · 2 min read · yeonnan.hashnode.dev  
Read the article

-   [#django](https://hashnode.com/tag/django)
-   [#django-rest-framework](https://hashnode.com/tag/django-rest-framework)

## Written by

[Dayeon](https://hashnode.com/@yeonan)

@yeonan

  
[View profile](https://hashnode.com/@yeonan)

## Responses 1

Markdown supported · ⌘↵ to post

[Park](https://hashnode.com/@Wooyeong)

[May 2, 2024](https://hashnode.com/posts/pk-username/66330ee468320de25f5f32d0/comment/66337a91cbd679493eb51438)

고생하였읍니다
