Comments (7)
totally agree, this is a duplicated of my issue #49 , take a look
I am using the way you are saying (switching the lines) and works perfectly.
from drf-writable-nested.
@isasiluispy @dz0 Hello! Thanks for the contribution. It really makes sense. I'll prepare a fix soon.
from drf-writable-nested.
I've found that your solution breaks some important tests.
from drf-writable-nested.
I've fixed another bug in delete method.
Now, only one test is broken when I switch update and delete:
WritableNestedModelSerializerTest.test_update_reverse_one_to_one_without_pk
This test covers functionality from this PR #36
from drf-writable-nested.
@ruscoder will this bug be fixed ? I think it's not wotking properly yet, for unique_together constraints
like this example #49 I still have to swicth the lines to get it working :(
from drf-writable-nested.
@isasiluispy Your suggested fix brakes functionality from #36. I don't know how we can fix it saving backward compatibility for the moment.
As for me, I don't understand the worth of #36, but a few people asked for this feature.
If you want, you can make a PR with fix for #36 and for this issue.
from drf-writable-nested.
To solve this problem, the logic in #36 needs to be moved into its own utility function and update
changed to:
self.materialize_one_to_one_pk(instance, reverse_relations) # code from #36 relocated here
self.delete_reverse_relations_if_need(instance, reverse_relations)
self.update_or_create_reverse_relations(instance, reverse_relations)
Hopefully that helps someone who's motivated. I can't help ATM because I'm just here to evaluate the project as a replacement for our DIY logic.
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.