We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Store need
{ 'name': 'category 1', 'children':[ {'name': 'category 2'}, {'name': 'category 3'}, ] }
I use djangorestframework and trying to write serializer for
class Category(MPTTModel): name = models.CharField(max_length=100) parent = TreeForeignKey('self', on_delete=models.CASCADE, null=True, blank=True, related_name='children') class MPTTMeta: order_insertion_by = ['name']
I made it
class CategorySerializer(serializers.ModelSerializer): class Meta: model = Category fields = ['id', 'name', 'children'] read_only_fields = ['parents'] # parent = serializers.ListField() children = RecursiveField('CategorySerializer', required=False, allow_null=True, many=True)
And I got the error TypeError: unhashable type: 'collections.OrderedDict'. It seems that the internal fields are not serialized.
TypeError: unhashable type: 'collections.OrderedDict'
The text was updated successfully, but these errors were encountered:
I think combining these two packages (django-mptt, drf-writable-nested) can solve your problem.
Sorry, something went wrong.
No branches or pull requests
Store need
I use djangorestframework and trying to write serializer for
I made it
And I got the error
TypeError: unhashable type: 'collections.OrderedDict'
. It seems that the internal fields are not serialized.The text was updated successfully, but these errors were encountered: