Python Django rest框架隐藏列逻辑

Python Django rest框架隐藏列逻辑,python,mysql,django,django-rest-framework,Python,Mysql,Django,Django Rest Framework,我有两个表(用户类型和原始数据),在列表方法中显示原始数据时,用户类型需要工具来隐藏原始数据列(即cid、eup等)明确地如何做到这一点?您必须像这样重写序列化程序的到\u表示法 def to_representation(self, instance): data = {} # Add data on the basis of user type in this dictionary return data 您必须像这样重写序列化程序的to_表示法方法 def to_

我有两个表(用户类型和原始数据),在列表方法中显示原始数据时,用户类型需要工具来隐藏原始数据列(即cid、eup等)明确地如何做到这一点?

您必须像这样重写序列化程序的
到\u表示法

def to_representation(self, instance):
    data = {}
    # Add data on the basis of user type in this dictionary
    return data

您必须像这样重写序列化程序的
to_表示法
方法

def to_representation(self, instance):
    data = {}
    # Add data on the basis of user type in this dictionary
    return data

添加更多信息?像数据格式和逗号一样,这将使其他人更容易帮助你回答问题添加更多信息?像数据格式和逗号一样,这将使其他人更容易帮助回答您的问题谢谢!!我还有一个问题,我们可以再制作一个表,隐藏字段可以保存在那里吗?你是说你想保存我们以前隐藏的字段吗?如果是,则类似于_表示方法,您可以编写自定义
create
方法。您应该详细了解django rest序列化程序。否则你会被卡在每一步上。谢谢!!我还有一个问题,我们可以再制作一个表,隐藏字段可以保存在那里吗?你是说你想保存我们以前隐藏的字段吗?如果是,则类似于_表示方法,您可以编写自定义
create
方法。您应该详细了解django rest序列化程序。否则你会在每一步上都卡住。