Comments (8)
is it fixed?
from drf-writable-nested.
@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.
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.
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.
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.
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.
@d3dc Hello! Can you check your issue with v0.4.3?
from drf-writable-nested.
this can be closed based on #42 (comment)
from drf-writable-nested.
Related Issues (20)
- "depth" property does not work? HOT 1
- You cannot call `.save()` after accessing `serializer.data`.If you need to access data before committing to the database then inspect 'serializer.validated_data' instead. HOT 2
- UniqueFieldMixin does not work for djangorestframwork of versions >= 3.11 HOT 1
- ValueError when trying to set a related id field to the wrong value HOT 1
- Parent instance is inaccesible in child validate data for reverse HOT 1
- Update nested related OneToOneField without providing its pk
- Delete reverse relations before update or create in NestedUpdateMixin HOT 4
- Migrate to new CI platform HOT 1
- Take into account the unique_together Models Meta field in UniqueFieldsMixin HOT 1
- The `.create()` method does not support writable nested fields by default
- Validation of child runs twice. Is this deliberate as it seems a bit inefficient to run the same code twice. HOT 5
- Error when trying to update reverse many-to-many relation
- Creating multiple objects with drf-writable-nested WritableNestedModelSerializer not creating the nested relation objects HOT 2
- how to use with self related field(manytomany)
- [Security] Changing related objects HOT 3
- Setting null when sending data as form data in one-to-one relationships
- The `.create()` method does not support writable nested fields by default. HOT 1
- Problem of pass through values to nested serializers from the call to the base serializer's save method. HOT 3
- Reverse Foreign Key is not working HOT 1
- Reverse FK relation got: TypeError: Car() got an unexpected keyword argument 'car_users'
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from drf-writable-nested.