File in nested serializer

Yametazamwa mara 78
Ruka hadi kwenye ujumbe wa kwanza ambao haujasomwa

narendra...@gmail.com

hayajasomwa,
15 Jun 2021, 01:18:2215/06/2021
kwa Django users
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. 

Nikeet NA

hayajasomwa,
15 Jun 2021, 05:04:1915/06/2021
kwa Django users

narendra thapa

hayajasomwa,
15 Jun 2021, 20:37:0415/06/2021
kwa django...@googlegroups.com
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

--
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...@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.

narendra thapa

hayajasomwa,
15 Jun 2021, 20:37:2915/06/2021
kwa django...@googlegroups.com
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:
--

Nikeet NA

hayajasomwa,
15 Jun 2021, 22:41:5515/06/2021
kwa django...@googlegroups.com
Can you show me your nested serializer code.

narendra thapa

hayajasomwa,
21 Jun 2021, 01:14:4421/06/2021
kwa django...@googlegroups.com
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

Jibu wote
Mjibu mchapishaji
Sambaza
Ujumbe 0 mpya