[Django]-Assertion error at: Django-rest-Framework

50👍

Read the DRF docs here.

In version 2.x a serializer class could sometimes automatically determine the queryset argument if a ModelSerializer class was being used.

This behavior is now replaced with always using an explicit queryset argument for writable relational fields.

You are just using a newer version of DRF than the authors of the code used, so you’ll need to either use a lower version or fix the code.

In serializers.py there’s this line:

assigned = serializers.SlugRelatedField(slug_field=User.USERNAME_FIELD, required=False)

You need to either add read_only=True or queryset=User.objects.all()

-2👍

In my case, read_only=True helped.

-3👍

you need remove RelatedField from your serializers it is no more supported by django.in my case it worked.

Leave a comment