Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi create not working ? #27

Open
kentuck13 opened this issue Nov 2, 2018 · 0 comments
Open

Multi create not working ? #27

kentuck13 opened this issue Nov 2, 2018 · 0 comments

Comments

@kentuck13
Copy link

class SectionSerializer(TranslatableModelSerializer):
    translations = TranslatedFieldsField(shared_model=Section)
    section_group = SectionGroupSerializer(many=True)

    class Meta:
        model = Section
        fields = (
            'translations',
            'min_age',
            'image',
            'section_group'
        )

    @transaction.atomic
    def create(self, validated_data):
        section_group = validated_data.pop('section_group')
        section = super().create(validated_data)

        section_group = [{**i, 'section': section.id} for i in section_group]
        serializer = SectionGroupSerializer(
            data=section_group,
            many=True
        )
        serializer.is_valid(raise_exception=True)
        serializer.save()

When i ran this code, i got exception:
self.model._meta.object_name, obj, TypeError: 'SectionGroupTranslation' instance expected, got 'uz'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant