添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

Paul,

With the new version 0.1.1 the assertion error persists. Then including the child:

tags = TagListSerializerField(child=models.CharField)

A new assertion error is generated.

web_1      |   File "/app/contratos/api/documents/serializers.py", line 8, in <module>
web_1      |     class TemplateSerializer(TaggitSerializer,serializers.ModelSerializer):
web_1      |   File "/app/contratos/api/documents/serializers.py", line 10, in TemplateSerializer
web_1      |     tags = TagListSerializerField(child=models.CharField)
web_1      |   File "/usr/local/lib/python2.7/site-packages/rest_framework/fields.py", line 1127, in __init__
web_1      |     assert not inspect.isclass(self.child), '`child` has not been instantiated.'
web_1      | AssertionError: `child` has not been instantiated.

regards,

Hi @jdcaballerov

That means that the child has to be initiated. So instead of doing this:

tags = TagListSerializerField(child=models.CharField)

You have to do this:

tags = TagListSerializerField(child=models.CharField()) #  Mind those () at the CharField

Note: if you update to 0.1.1 you don't have to do this anymore.

Closing this issue!

Paul @glemmaPaul ,

Unfortunately that's not the case. Even installing 0.1.1 that persists.
Instantiating neither solves. Unfortunately at the moment I am not familiar with the inner workings of DRF to be able help solving the issues.

web_1      |     class TemplateSerializer(TaggitSerializer,serializers.ModelSerializer):
web_1      |   File "/app/contratos/api/documents/serializers.py", line 10, in TemplateSerializer
web_1      |     tags = TagListSerializerField(child=models.CharField())
web_1      |   File "/usr/local/lib/python2.7/site-packages/rest_framework/fields.py", line 1129, in __init__
web_1      |     self.child.bind(field_name='', parent=self)
web_1      | TypeError: bind() got an unexpected keyword argument 'field_name'

regards,