Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internal server error: MultipleObjectsReturned - get() returned more than one Choice -- it returned 2! #712

Open
matthiaskoenig opened this issue Feb 17, 2021 · 1 comment
Assignees

Comments

@matthiaskoenig
Copy link
Owner

MultipleObjectsReturned at /api/v1/_studies/PKDB00165/
get() returned more than one Choice -- it returned 2!

On
/api/v1/_studies/PKDB00165/
/api/v1/_studies/PKDB00191/

 File "/code/pkdb_app/subjects/serializers.py", line 443, in to_internal_value
    return super(serializers.ModelSerializer, self).to_internal_value(data)
  File "/usr/local/lib/python3.7/site-packages/rest_framework/serializers.py", line 490, in to_internal_value
    validated_value = field.run_validation(primitive_value)
  File "/usr/local/lib/python3.7/site-packages/rest_framework/serializers.py", line 621, in run_validation
    value = self.to_internal_value(data)
  File "/usr/local/lib/python3.7/site-packages/rest_framework/serializers.py", line 657, in to_internal_value
    validated = self.child.run_validation(item)
  File "/usr/local/lib/python3.7/site-packages/rest_framework/serializers.py", line 436, in run_validation
    value = self.validate(value)
  File "/code/pkdb_app/subjects/serializers.py", line 103, in validate
    attrs["choice"] = attrs["measurement_type"].validate_complete(data=attrs, time_allowed=False)["choice"]
  File "/code/pkdb_app/info_nodes/models.py", line 379, in validate_complete
    d_choice = self.validate_choice(choice)
  File "/code/pkdb_app/info_nodes/models.py", line 330, in validate_choice
    return self.choices.get(info_node__name=choice)
  File "/usr/local/lib/python3.7/site-packages/django/db/models/query.py", line 436, in get
    num if not limit or num < limit else 'more than %s' % (limit - 1),
@matthiaskoenig
Copy link
Owner Author

@janekg89 Add a uniqueness contraint on info_node.name. Also in pkdb_data the uniqueness of names must be checked in the validation of the info nodes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants