ok, i'm grateful for everyone‘s help , i know what i should do 在2022年8月15日星期一 UTC+8 14:08:44<[email protected]> 写道:
> It will be better if you create multiple serializers for the same model . > For example , you can use a serializer for retrieve view and another > serializer for the List view > > On Mon, 15 Aug 2022 at 11:34 AM, bozi young <[email protected]> wrote: > >> i'm sorry, please excuse my ignorance, what is the " >> ACTION_MAPPING_SERIALIZER[self.action] "? >> could you give me a real example ? >> I fondly anticipate your reply ,thank you . >> >> >> Linh Hoàng Ngọc <[email protected]> 于2022年8月15日周一 13:47写道: >> >>> In this view, we can switch serializers to the following the method. >>> Refer: >>> ```def get_serializer_class(self): # type: ignore >>> return ACTION_MAPPING_SERIALIZER[self.action] >>> ``` >>> Vào lúc 09:03:21 UTC+7 ngày Thứ Hai, 15 tháng 8, 2022, [email protected] >>> đã viết: >>> >>>> hi , guys. >>>> i created a article model that has three fields; Id 、title 、content; >>>> i created a article ModelSerializer class about the article model。 >>>> but sometime i want to only serialize partly fields(example:id、title , >>>> in the listview), >>>> sometime i want to serialize all of the fields (example: id >>>> 、title、content, in the retrieve view) >>>> if i only have a ModelSerializer class, what should i do ? >>>> >>>> please let me know. >>>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Django REST framework" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to [email protected]. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/django-rest-framework/3bc2d80a-2803-4041-85aa-a372fdc155dan%40googlegroups.com >>> >>> <https://groups.google.com/d/msgid/django-rest-framework/3bc2d80a-2803-4041-85aa-a372fdc155dan%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django REST framework" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> > To view this discussion on the web visit >> https://groups.google.com/d/msgid/django-rest-framework/CAGVKvXcx1mO_rbtRKSV%2B1SAqV-jn_A8S1aEvADG8ytqqVN%2B4%2BA%40mail.gmail.com >> >> <https://groups.google.com/d/msgid/django-rest-framework/CAGVKvXcx1mO_rbtRKSV%2B1SAqV-jn_A8S1aEvADG8ytqqVN%2B4%2BA%40mail.gmail.com?utm_medium=email&utm_source=footer> >> . >> > -- > *Abhishek Chauhan* > > ✆ : 9560 432 275 > > *@abhiazh* <https://twitter.com/abhiazh> > > > > > -- You received this message because you are subscribed to the Google Groups "Django REST framework" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/django-rest-framework/f7f5c5ff-028b-4295-8079-e6e3542e0d21n%40googlegroups.com.
