Closed tkhyn closed 9 years ago
Original comment by Thomas Khyn (Bitbucket: tkhyn, GitHub: tkhyn).
Well, it looks like 0.2.6 will have to wait a little bit.
What if you apply this patch:
diff -r cf6858a6e354 gm2m/relations.py
--- a/gm2m/relations.py Thu Apr 23 15:53:12 2015 +1200
+++ b/gm2m/relations.py Fri Apr 24 13:56:23 2015 +1200
@@ -36,6 +36,7 @@
Each related model has a GM2MRelation towards the source model
"""
+ one_to_many = True
concrete = False
generate_reverse_relation = False # only used in Django 1.7
related_accessor_class = GM2MRelatedDescriptor
Original comment by Paul Collins (Bitbucket: paulcollinsiii, GitHub: paulcollinsiii).
That improves things for sure, but now I'm running into
Traceback (most recent call last):
File "/Users/paulcollins/workspace/datanav/backend/tests/functional/test_entity/test_api.py", line 182, in test_add_phone_other
serializer.data['phone_other'].append(model_to_dict(phone))
File "/opt/boxen/data/virtualenvs/di_py34/lib/python3.4/site-packages/rest_framework/serializers.py", line 466, in data
ret = super(Serializer, self).data
File "/opt/boxen/data/virtualenvs/di_py34/lib/python3.4/site-packages/rest_framework/serializers.py", line 213, in data
self._data = self.to_representation(self.instance)
File "/opt/boxen/data/virtualenvs/di_py34/lib/python3.4/site-packages/rest_framework/serializers.py", line 422, in to_representation
fields = [field for field in self.fields.values() if not field.write_only]
File "/opt/boxen/data/virtualenvs/di_py34/lib/python3.4/site-packages/rest_framework/serializers.py", line 313, in fields
for key, value in self.get_fields().items():
File "/opt/boxen/data/virtualenvs/di_py34/lib/python3.4/site-packages/rest_framework/serializers.py", line 836, in get_fields
info = model_meta.get_field_info(model)
File "/opt/boxen/data/virtualenvs/di_py34/lib/python3.4/site-packages/rest_framework/utils/model_meta.py", line 68, in get_field_info
reverse_relations = _get_reverse_relationships(opts)
File "/opt/boxen/data/virtualenvs/di_py34/lib/python3.4/site-packages/rest_framework/utils/model_meta.py", line 135, in _get_reverse_relationships
to_many=relation.field.rel.multiple,
AttributeError: 'GM2MRel' object has no attribute 'multiple'
This is with DRF 3.1.1. I'm not positive this is GM2M related so I'll dig into this more today and report back.
Original comment by Thomas Khyn (Bitbucket: tkhyn, GitHub: tkhyn).
It's almost certainly gm2m related, as the multiple
attribute is expected by Django internals for the object that is accessible as the rel
attribute of a RelatedField
, and gm2m hasn't been told to set this attribute yet.
You can try adding the line below:
#!
diff -r cf6858a6e354 gm2m/relations.py
--- a/gm2m/relations.py Thu Apr 23 15:53:12 2015 +1200
+++ b/gm2m/relations.py Sat Apr 25 16:23:15 2015 +1200
@@ -20,6 +20,7 @@
# default relation attributes
REL_ATTRS = {
+ 'multiple': True,
'related_name': None,
'related_query_name': None,
'through': None,
Original comment by Paul Collins (Bitbucket: paulcollinsiii, GitHub: paulcollinsiii).
That appears to resolve that particular set of test failures for me. I'm working through the rest of my test suite still. Several other upgrade problems that aren't related to gm2m. At this point I'm pretty sure you're good to release 0.2.6
Original report by Paul Collins (Bitbucket: paulcollinsiii, GitHub: paulcollinsiii).
While running my tests, I'm getting a new traceback
This is with 168:5254d90a4dbc from the fix to #5