Coder Social home page Coder Social logo

Comments (8)

auvipy avatar auvipy commented on September 16, 2024 2

is it fixed?

from drf-writable-nested.

ruscoder avatar ruscoder commented on September 16, 2024

@danilke Hello! Could you please provide more information?
I'm intrested in the samples of serializer's code and the samples of data which you send.

from drf-writable-nested.

danilke avatar danilke commented on September 16, 2024

Thank you for so fast feedback! Looks like problem is in my low skill in django, because I have tried to save object from console with UserSerializer, and it went fine.

models.py

class Profile(models.Model):
    user = models.OneToOneField(User)
    city = models.CharField(max_length=50, blank=True, default='')
    phone = models.CharField(max_length=50, blank=True, default='')

serializers.py

class ProfileSerializer(serializers.ModelSerializer):
    class Meta:
        model = Profile
        fields = ('pk', 'city', 'phone',)


class UserSerializer(WritableNestedModelSerializer):
    profile = ProfileSerializer(allow_null=True, many=False)

    class Meta:
        model = User
        fields = (
            'pk',
            'url',
            'username',
            'email',
            'groups',
            'profile',
            )

Where can be problem? One more tine thanks a lot!

from drf-writable-nested.

danilke avatar danilke commented on September 16, 2024

Hm, I was trying to send data from "browsable api" in DRF, and its went wrong, but when I've sended json from postman, was saved without any error :) Thank you for nice library :) It saved me a lot of time!

from drf-writable-nested.

rainyx avatar rainyx commented on September 16, 2024

Same problem, when using multipart formatted data, MultiValueDictKeyError will be raised.

Some MultiValueDict data like this:

data = {
   'a.title': 'xxxxx',
   'a.desc': 'vvvvvv'
}

from drf-writable-nested.

d3dc avatar d3dc commented on September 16, 2024

I'm hitting this issue in my code

drf_writable_nested/mixins.py", line 122, in update_or_create_reverse_relations
    related_data = self.initial_data[field_name]

MultiValueDictKeyError: "'offices'"

 

As @rainyx mentioned, this seems to happen with multipart form data.

I'm sending a partial update with the body:

------WebKitFormBoundaryBxUozciZvqZAB7cj
Content-Disposition: form-data; name="org_image"; filename="Group.png"
Content-Type: image/png

------WebKitFormBoundaryBxUozciZvqZAB7cj--

In my serializer, however, I get extra validated_data:

{ 'org_image': <InMemoryUploadedFile: Group.png (image/png)>, 'offices': [] }

(offices is a writable nested ManyToMany with a standard serializer)

from drf-writable-nested.

ruscoder avatar ruscoder commented on September 16, 2024

@d3dc Hello! Can you check your issue with v0.4.3?

from drf-writable-nested.

auvipy avatar auvipy commented on September 16, 2024

this can be closed based on #42 (comment)

from drf-writable-nested.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.