AttributeError: 'ManyJsonLdRelatedField' object has no attribute 'child'
On United4Earth, I have the ActionGroup
model :
https://git.happy-dev.fr/startinblox/applications/united4earth/blob/dev/data_manager/models.py#L90
It has a ManyToMany
relationship to itself :
actiongroups = models.ManyToManyField("self", blank=True)
When I create an ActionGroup
and try to associate two together, I get the following error :
AttributeError at /api/actiongroups/
'ManyJsonLdRelatedField' object has no attribute 'child'
Request Method: POST
Request URL: http://127.0.0.1:8000/api/actiongroups/
Django Version: 1.11.20
Python Executable: /usr/bin/python3
Python Version: 3.6.7
Python Path: ['/var/www/united4earth', '/usr/lib/python36.zip', '/usr/lib/python3.6', '/usr/lib/python3.6/lib-dynload', '/home/alex/.local/lib/python3.6/site-packages', '/usr/local/lib/python3.6/dist-packages', '/usr/lib/python3/dist-packages']
Server time: ven, 17 Mai 2019 08:03:05 +0200
Installed Applications:
['united4earth',
'data_manager',
'djangoldp_conversation',
'djangoldp',
'guardian',
'registration',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware']
Traceback:
File "/home/alex/.local/lib/python3.6/site-packages/django/core/handlers/exception.py" in inner
41. response = get_response(request)
File "/home/alex/.local/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
187. response = self.process_exception_by_middleware(e, request)
File "/home/alex/.local/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
185. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/alex/.local/lib/python3.6/site-packages/django/views/decorators/csrf.py" in wrapped_view
58. return view_func(*args, **kwargs)
File "/home/alex/.local/lib/python3.6/site-packages/rest_framework/viewsets.py" in view
116. return self.dispatch(request, *args, **kwargs)
File "/home/alex/.local/lib/python3.6/site-packages/djangoldp/views.py" in dispatch
136. response = super(LDPViewSet, self).dispatch(request, *args, **kwargs)
File "/home/alex/.local/lib/python3.6/site-packages/rest_framework/views.py" in dispatch
495. response = self.handle_exception(exc)
File "/home/alex/.local/lib/python3.6/site-packages/rest_framework/views.py" in handle_exception
455. self.raise_uncaught_exception(exc)
File "/home/alex/.local/lib/python3.6/site-packages/rest_framework/views.py" in dispatch
492. response = handler(request, *args, **kwargs)
File "/home/alex/.local/lib/python3.6/site-packages/rest_framework/mixins.py" in create
20. serializer.is_valid(raise_exception=True)
File "/home/alex/.local/lib/python3.6/site-packages/rest_framework/serializers.py" in is_valid
236. self._validated_data = self.run_validation(self.initial_data)
File "/home/alex/.local/lib/python3.6/site-packages/rest_framework/serializers.py" in run_validation
434. value = self.to_internal_value(data)
File "/home/alex/.local/lib/python3.6/site-packages/rest_framework/serializers.py" in to_internal_value
491. validated_value = field.run_validation(primitive_value)
File "/home/alex/.local/lib/python3.6/site-packages/rest_framework/fields.py" in run_validation
535. value = self.to_internal_value(data)
File "/home/alex/.local/lib/python3.6/site-packages/djangoldp/serializers.py" in to_internal_value
34. return [self.child.to_internal_value(item) for item in data]
File "/home/alex/.local/lib/python3.6/site-packages/djangoldp/serializers.py" in <listcomp>
34. return [self.child.to_internal_value(item) for item in data]
Exception Type: AttributeError at /api/actiongroups/
Exception Value: 'ManyJsonLdRelatedField' object has no attribute 'child'
Sent JSON :
[
{
"@id": "./",
"http://happy-dev.fr/owl/#actiongroups": {
"@id": "http://127.0.0.1:8000/api/actiongroups/1/"
},
"http://happy-dev.fr/owl/#description": "Test ManyToMany association",
"http://happy-dev.fr/owl/#frequency": {
"@id": "http://127.0.0.1:8000/api/actiongroupfrequencys/1/"
},
"http://happy-dev.fr/owl/#image": "https://www.fodors.com/wp-content/uploads/2018/07/shutterstock_552368572.jpg",
"http://happy-dev.fr/owl/#kind": {
"@id": "http://127.0.0.1:8000/api/actiongroupthemes/1/"
},
"http://happy-dev.fr/owl/#objective": "Test ManyToMany association",
"http://happy-dev.fr/owl/#place": "My laptop",
"http://www.w3.org/2000/01/rdf-schema#label": "Test ManyToMany association"
}
]