class CompanySerializer(serializers.ModelSerializer): company_contact = CompanyContactDetailsGet(many=True,required=False) company_logo_details = CompanyLogoGet(many=True,required=False)
class Meta: model = company_details fields = ('id','company_name','company_address','company_email', 'company_contact','company_logo_details') def create(self,validated_data): print("company_data",validated_data) company_contact_no = validated_data.pop('company_contact') print("company_contact",company_contact_no) # company_logo_data = validated_data.pop('company_logo_details') with transaction.atomic(): company = company_details.objects.create(**validated_data) # company_logo.objects.filter(Q(is_deleted_flag='n') | Q(company=company)).update(is_deleted_flag='y') # for data in company_logo_data: # companyLogo = company_logo.objects.create(company=company,**company_logo_data) for contact in company_contact_no: print("contactsss",contact,company) # contact['company'] = company company_contact_details.objects.create(company=company,** contact) return validated_data On Wed, Jun 16, 2021 at 8:26 AM Nikeet NA <nik...@exiverlabs.co.in> wrote: > Can you show me your nested serializer code. > > On Wed, 16 Jun 2021 at 06:07, narendra thapa <narendrathapa...@gmail.com> > wrote: > >> Actual problem is nested serializer is not accepting a QueryDIct data it >> accepts only the parent data and delete the child automatically. when i >> parse the QueryDIct data to JSON json.dumps() it will accept the child one >> but problem here is json.dumps() cannot convert InMEmoryField data type. So >> what will be the best way to do it. If you have some idea please share with >> me >> >> >> On Tue, Jun 15, 2021 at 2:49 PM Nikeet NA <nik...@exiverlabs.co.in> >> wrote: >> >>> Use This Drf nested serializer >>> <https://pypi.org/project/drf-nested-serializer/> >>> >>> On Tuesday, 15 June 2021 at 10:48:22 UTC+5:30 narendra...@gmail.com >>> wrote: >>> >>>> Hi Folks, >>>> I'm having a problem to insert a data in nested serializers with >>>> FileField. If anybody know the idea of doing that would you guys please >>>> just help me out. I googled it for the solution but found the problem asked >>>> but not a solution. And somewhere in git i found that it is hard to manged >>>> with nested serializers with file field. >>>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Django users" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to django-users+unsubscr...@googlegroups.com. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/django-users/588eed3a-7900-443c-9e9f-124136ba3933n%40googlegroups.com >>> <https://groups.google.com/d/msgid/django-users/588eed3a-7900-443c-9e9f-124136ba3933n%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to django-users+unsubscr...@googlegroups.com. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/django-users/CAEtntjX4-U9xzVCj-zWN1%2BC_EeTm2--%3D8KYQzSmW2%2BaEqKnaqw%40mail.gmail.com >> <https://groups.google.com/d/msgid/django-users/CAEtntjX4-U9xzVCj-zWN1%2BC_EeTm2--%3D8KYQzSmW2%2BaEqKnaqw%40mail.gmail.com?utm_medium=email&utm_source=footer> >> . >> > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to django-users+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/CAFOOHnM15R2Y%2BRxuFas-PWZSLRenLPnGqZ1JPikig-DfTQ5d_Q%40mail.gmail.com > <https://groups.google.com/d/msgid/django-users/CAFOOHnM15R2Y%2BRxuFas-PWZSLRenLPnGqZ1JPikig-DfTQ5d_Q%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAEtntjXy3F708VoyNvc7%2BGDCfc4gq%2BUYx3MOxWokhom3grAviw%40mail.gmail.com.