TypeError at /datawizard/
int() argument must be a string, a bytes-like object or a number, not 'ContentType'
Serializer passes set of ContentType objects to ContentTypeIdField:
class RunSerializer(serializers.ModelSerializer):
user = serializers.HiddenField(default=serializers.CurrentUserDefault())
content_type_id = ContentTypeIdField(queryset=ContentType.objects.all()) <---
This object is received by to_representation with the name content_type_id, although it is the instance. pk=content_type_id fails with a TypeError as it tries to cast content_type_id to an int so it can perform the lookup.
Fix for:
Serializer passes set of
ContentType
objects toContentTypeIdField
:This object is received by
to_representation
with the namecontent_type_id
, although it is the instance.pk=content_type_id
fails with aTypeError
as it tries to castcontent_type_id
to anint
so it can perform the lookup.Fixed by passing the PK instead: