save() got an unexpected keyword argument 'force_insert' with django-rest-framework?
See original GitHub issueIt looks like there is a problem for me with django-rest-framework and django-ldapdb save() function.
In the save object force_insert=False is included, and things goes haywire 😃 This was a fugly fix for me, any ideas what goest wrong and what I can do to not hardcode base.py?
models/base.py
65c65
< def save(self, using=None):
---
> def save(self, using=None, *args, **kvargs):
This is the installed packages…
pip freeze
Django==1.9.9
django-ldapdb==0.6.0
djangorestframework==3.4.6
pkg-resources==0.0.0
pyldap==2.4.25.1
And the Traceback
Traceback (most recent call last):
File "/home/falk/env/ldapdbtest/lib/python3.5/site-packages/django/core/handlers/base.py", line 149, in get_response
response = self.process_exception_by_middleware(e, request)
File "/home/falk/env/ldapdbtest/lib/python3.5/site-packages/django/core/handlers/base.py", line 147, in get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/falk/env/ldapdbtest/lib/python3.5/site-packages/django/views/decorators/csrf.py", line 58, in wrapped_view
return view_func(*args, **kwargs)
File "/home/falk/env/ldapdbtest/lib/python3.5/site-packages/django/views/generic/base.py", line 68, in view
return self.dispatch(request, *args, **kwargs)
File "/home/falk/env/ldapdbtest/lib/python3.5/site-packages/rest_framework/views.py", line 474, in dispatch
response = self.handle_exception(exc)
File "/home/falk/env/ldapdbtest/lib/python3.5/site-packages/rest_framework/views.py", line 434, in handle_exception
self.raise_uncaught_exception(exc)
File "/home/falk/env/ldapdbtest/lib/python3.5/site-packages/rest_framework/views.py", line 471, in dispatch
response = handler(request, *args, **kwargs)
File "/home/falk/dev/ldapdbtest/d1xldap/views.py", line 34, in post
serializer.save()
File "/home/falk/env/ldapdbtest/lib/python3.5/site-packages/rest_framework/serializers.py", line 192, in save
self.instance = self.create(validated_data)
File "/home/falk/dev/ldapdbtest/d1xldap/serializers.py", line 12, in create
return Device.objects.create(**validated_data)
File "/home/falk/env/ldapdbtest/lib/python3.5/site-packages/django/db/models/manager.py", line 122, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/home/falk/env/ldapdbtest/lib/python3.5/site-packages/django/db/models/query.py", line 401, in create
obj.save(force_insert=True, using=self.db)
TypeError: save() got an unexpected keyword argument 'force_insert'
Regards Falk
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
TypeError - save() got an unexpected keyword argument ...
It gave TypeError - save() got an unexpected keyword argument 'force_insert'. I tested the code below and they were able to save the...
Read more >save() got an unexpected keyword argument 'force_insert ...
I got this error message, please i need help. ValueError at /post/new/ Cannot assign "<SimpleLazyObject: <django.contrib.auth.models.
Read more >Overriding save() raises error when using Model.objects.create()
It seems that when over writing .save() (and maybe other default methods) you ... Exception Value: save() got an unexpected keyword argument 'force_insert'....
Read more >Calling serializer.save() method with additional argument ...
to django-res. ... In DRF 2.4 calling a serializer save method gives the following error, why: ... "save() got an unexpected keyword argument...
Read more >Django TypeError: render() got an unexpected keyword ...
Support for Widget.render() methods without the renderer argument is removed. You may have subclassed django.forms.widgets.Widget in your code, or in ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Fixed as 25ae984.
Indeed, the
ldapdb.models.Model.save()
signature is incorrect.Thanks for the report!