Urgent: PUT on Review results in error
I got another issue, getting it before update. When I am doing an update through a PUT on /reviews/{id} on my server I got this on the server log:
[03/Sep/2019 10:02:52] "OPTIONS /reviews/36/ HTTP/1.1" 200 256
Internal Server Error: /reviews/36/
Traceback (most recent call last):
File "/home/balessan/.local/lib/python3.6/site-packages/django/core/handlers/exception.py", line 41, in inner
response = get_response(request)
File "/home/balessan/.local/lib/python3.6/site-packages/django/core/handlers/base.py", line 187, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/home/balessan/.local/lib/python3.6/site-packages/django/core/handlers/base.py", line 185, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/balessan/.local/lib/python3.6/site-packages/django/views/decorators/csrf.py", line 58, in wrapped_view
return view_func(*args, **kwargs)
File "/home/balessan/.local/lib/python3.6/site-packages/rest_framework/viewsets.py", line 114, in view
return self.dispatch(request, *args, **kwargs)
File "/home/balessan/.local/lib/python3.6/site-packages/djangoldp/views.py", line 204, in dispatch
response = super(LDPViewSet, self).dispatch(request, *args, **kwargs)
File "/home/balessan/.local/lib/python3.6/site-packages/rest_framework/views.py", line 497, in dispatch
response = self.handle_exception(exc)
File "/home/balessan/.local/lib/python3.6/site-packages/rest_framework/views.py", line 457, in handle_exception
self.raise_uncaught_exception(exc)
File "/home/balessan/.local/lib/python3.6/site-packages/rest_framework/views.py", line 468, in raise_uncaught_exception
raise exc
File "/home/balessan/.local/lib/python3.6/site-packages/rest_framework/views.py", line 494, in dispatch
response = handler(request, *args, **kwargs)
File "/home/balessan/.local/lib/python3.6/site-packages/djangoldp/views.py", line 153, in update
self.perform_update(serializer)
File "/home/balessan/.local/lib/python3.6/site-packages/rest_framework/mixins.py", line 78, in perform_update
serializer.save()
File "/home/balessan/.local/lib/python3.6/site-packages/rest_framework/serializers.py", line 208, in save
self.instance = self.update(self.instance, validated_data)
File "/home/balessan/.local/lib/python3.6/site-packages/djangoldp/serializers.py", line 518, in update
value = self.update_dict_value(attr, instance, value)
File "/home/balessan/.local/lib/python3.6/site-packages/djangoldp/serializers.py", line 535, in update_dict_value
value = self.update_dict_value_when_id_is_provided(attr, instance, relation_info, slug_field, value)
File "/home/balessan/.local/lib/python3.6/site-packages/djangoldp/serializers.py", line 560, in update_dict_value_when_id_is_provided
value = self.update(instance=oldObj, validated_data=value)
File "/home/balessan/.local/lib/python3.6/site-packages/djangoldp/serializers.py", line 522, in update
setattr(instance, attr, value)
AttributeError: 'NoneType' object has no attribute 'pk'
[03/Sep/2019 10:12:42] "PUT /reviews/36/ HTTP/1.1" 500 19429
The detail of the request is the following:
curl 'http://localhost:8000/reviews/36/' -X PUT -H 'User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:68.0) Gecko/20100101 Firefox/68.0' -H 'Accept: */*' -H 'Accept-Language: en-US,en;q=0.5' --compressed -H 'Referer: http://localhost:9000/mentor-dashboard/mentor-resource-validate/@http~@~_~_localhost~@8000~_resources~_4~_' -H 'Content-Type: application/ld+json' -H 'If-Match: undefined' -H 'Origin: http://localhost:9000' -H 'Connection: keep-alive' -H 'Cookie: csrftoken=Uiu7OVsMcoOGDSSlfqzMwLwKl9NTtfr6WEga8ePQUN7bo2MRcOyhw6GuMZ0ceS4h; sessionid=6rl2lgy4z5wpsaapik6438g8qdglhach' -H 'Pragma: no-cache' -H 'Cache-Control: no-cache' --data '[{"@id":"http://localhost:8000/reviews/36/","http://happy-dev.fr/owl/#reviewer":{"@id":"http://localhost:8000/users/1/"},"http://happy-dev.fr/owl/#status":"validated"}]'
It's linked to the version of the models.py available here
It could be linked to the fact that I am trying to update the reviewer field which is defined as the auto_author. I may have to remove that.
It looks like a bug to @sylvain after quick screensharing. It's blocking for me :-D
Edited by Benoit Alessandroni